[dpdk-dev,3/4] app/testpmd: add option to avoid lock all memory

Message ID 1518580892-32656-4-git-send-email-jianfeng.tan@intel.com
State Superseded, archived
Delegated to: Thomas Monjalon
Headers show

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/checkpatch warning coding style issues

Commit Message

Jianfeng Tan Feb. 14, 2018, 4:01 a.m.
In some cases, we don't want to lock all memory.

Add an option --no-mlockall to avoid lock all memory.

Cc: wenzhuo.lu@intel.com
Cc: jingjing.wu@intel.com

Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>
---
 app/test-pmd/parameters.c |  5 ++++-
 app/test-pmd/testpmd.c    | 32 ++++++++++++++++++--------------
 app/test-pmd/testpmd.h    |  1 +
 3 files changed, 23 insertions(+), 15 deletions(-)

Comments

Wu, Jingjing Feb. 14, 2018, 6:40 a.m. | #1
New options is added, the doc also need to update.


> -----Original Message-----
> From: Tan, Jianfeng
> Sent: Wednesday, February 14, 2018 12:02 PM
> To: dev@dpdk.org
> Cc: Tan, Jianfeng <jianfeng.tan@intel.com>; Lu, Wenzhuo <wenzhuo.lu@intel.com>; Wu,
> Jingjing <jingjing.wu@intel.com>
> Subject: [PATCH 3/4] app/testpmd: add option to avoid lock all memory
> 
> In some cases, we don't want to lock all memory.
> 
> Add an option --no-mlockall to avoid lock all memory.
> 
> Cc: wenzhuo.lu@intel.com
> Cc: jingjing.wu@intel.com
> 
> Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>
> ---
>  app/test-pmd/parameters.c |  5 ++++-
>  app/test-pmd/testpmd.c    | 32 ++++++++++++++++++--------------
>  app/test-pmd/testpmd.h    |  1 +
>  3 files changed, 23 insertions(+), 15 deletions(-)
> 
> diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c
> index 97d22b8..5060a6c 100644
> --- a/app/test-pmd/parameters.c
> +++ b/app/test-pmd/parameters.c
> @@ -186,6 +186,7 @@ usage(char* progname)
>  	printf("  --flow-isolate-all: "
>  	       "requests flow API isolated mode on all ports at initialization time.\n");
>  	printf("  --tx-offloads=0xXXXXXXXX: hexadecimal bitmask of TX queue offloads\n");
> +	printf("  --no-mlockall: do not lock all memory\n");
>  }
> 
>  #ifdef RTE_LIBRTE_CMDLINE
> @@ -621,6 +622,7 @@ launch_args_parse(int argc, char** argv)
>  		{ "print-event",		1, 0, 0 },
>  		{ "mask-event",			1, 0, 0 },
>  		{ "tx-offloads",		1, 0, 0 },
> +		{ "no-mlockall",		0, 0, 0 },
>  		{ 0, 0, 0, 0 },
>  	};
> 
> @@ -1102,7 +1104,8 @@ launch_args_parse(int argc, char** argv)
>  					rte_exit(EXIT_FAILURE,
>  						 "invalid mask-event argument\n");
>  				}
> -
> +			if (!strcmp(lgopts[opt_idx].name, "no-mlockall"))
> +				no_mlockall = 1;
>  			break;
>  		case 'h':
>  			usage(argv[0]);
> diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
> index 4c0e258..59bdc85 100644
> --- a/app/test-pmd/testpmd.c
> +++ b/app/test-pmd/testpmd.c
> @@ -294,6 +294,10 @@ uint32_t event_print_mask = (UINT32_C(1) <<
> RTE_ETH_EVENT_UNKNOWN) |
>  			    (UINT32_C(1) << RTE_ETH_EVENT_INTR_RESET) |
>  			    (UINT32_C(1) << RTE_ETH_EVENT_MACSEC) |
>  			    (UINT32_C(1) << RTE_ETH_EVENT_INTR_RMV);
> +/*
> + * Decide if all memory are locked for performance.
> + */
> +int no_mlockall = 0;
> 
>  /*
>   * NIC bypass mode configuration options.
> @@ -2489,7 +2493,20 @@ main(int argc, char** argv)
>  		rte_panic("Cannot register log type");
>  	rte_log_set_level(testpmd_logtype, RTE_LOG_DEBUG);
> 
> -	if (mlockall(MCL_CURRENT | MCL_FUTURE)) {
> +	/* Bitrate/latency stats disabled by default */
> +#ifdef RTE_LIBRTE_BITRATE
> +	bitrate_enabled = 0;
> +#endif
> +#ifdef RTE_LIBRTE_LATENCY_STATS
> +	latencystats_enabled = 0;
> +#endif
> +
> +	argc -= diag;
> +	argv += diag;
> +	if (argc > 1)
> +		launch_args_parse(argc, argv);
> +
> +	if (!no_mlockall && mlockall(MCL_CURRENT | MCL_FUTURE)) {
>  		TESTPMD_LOG(NOTICE, "mlockall() failed with error \"%s\"\n",
>  			strerror(errno));
>  	}
> @@ -2511,19 +2528,6 @@ main(int argc, char** argv)
>  		rte_panic("Empty set of forwarding logical cores - check the "
>  			  "core mask supplied in the command parameters\n");
> 
> -	/* Bitrate/latency stats disabled by default */
> -#ifdef RTE_LIBRTE_BITRATE
> -	bitrate_enabled = 0;
> -#endif
> -#ifdef RTE_LIBRTE_LATENCY_STATS
> -	latencystats_enabled = 0;
> -#endif
> -
> -	argc -= diag;
> -	argv += diag;
> -	if (argc > 1)
> -		launch_args_parse(argc, argv);
> -
>  	if (tx_first && interactive)
>  		rte_exit(EXIT_FAILURE, "--tx-first cannot be used on "
>  				"interactive mode.\n");
> diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
> index 153abea..028b873 100644
> --- a/app/test-pmd/testpmd.h
> +++ b/app/test-pmd/testpmd.h
> @@ -319,6 +319,7 @@ extern volatile int test_done; /* stop packet forwarding when set
> to 1. */
>  extern uint8_t lsc_interrupt; /**< disabled by "--no-lsc-interrupt" parameter */
>  extern uint8_t rmv_interrupt; /**< disabled by "--no-rmv-interrupt" parameter */
>  extern uint32_t event_print_mask;
> +extern int no_mlockall; /**< set by "--no-mlockall" parameter */
>  /**< set by "--print-event xxxx" and "--mask-event xxxx parameters */
> 
>  #ifdef RTE_LIBRTE_IXGBE_BYPASS
> --
> 2.7.4

Patch

diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c
index 97d22b8..5060a6c 100644
--- a/app/test-pmd/parameters.c
+++ b/app/test-pmd/parameters.c
@@ -186,6 +186,7 @@  usage(char* progname)
 	printf("  --flow-isolate-all: "
 	       "requests flow API isolated mode on all ports at initialization time.\n");
 	printf("  --tx-offloads=0xXXXXXXXX: hexadecimal bitmask of TX queue offloads\n");
+	printf("  --no-mlockall: do not lock all memory\n");
 }
 
 #ifdef RTE_LIBRTE_CMDLINE
@@ -621,6 +622,7 @@  launch_args_parse(int argc, char** argv)
 		{ "print-event",		1, 0, 0 },
 		{ "mask-event",			1, 0, 0 },
 		{ "tx-offloads",		1, 0, 0 },
+		{ "no-mlockall",		0, 0, 0 },
 		{ 0, 0, 0, 0 },
 	};
 
@@ -1102,7 +1104,8 @@  launch_args_parse(int argc, char** argv)
 					rte_exit(EXIT_FAILURE,
 						 "invalid mask-event argument\n");
 				}
-
+			if (!strcmp(lgopts[opt_idx].name, "no-mlockall"))
+				no_mlockall = 1;
 			break;
 		case 'h':
 			usage(argv[0]);
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 4c0e258..59bdc85 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -294,6 +294,10 @@  uint32_t event_print_mask = (UINT32_C(1) << RTE_ETH_EVENT_UNKNOWN) |
 			    (UINT32_C(1) << RTE_ETH_EVENT_INTR_RESET) |
 			    (UINT32_C(1) << RTE_ETH_EVENT_MACSEC) |
 			    (UINT32_C(1) << RTE_ETH_EVENT_INTR_RMV);
+/*
+ * Decide if all memory are locked for performance.
+ */
+int no_mlockall = 0;
 
 /*
  * NIC bypass mode configuration options.
@@ -2489,7 +2493,20 @@  main(int argc, char** argv)
 		rte_panic("Cannot register log type");
 	rte_log_set_level(testpmd_logtype, RTE_LOG_DEBUG);
 
-	if (mlockall(MCL_CURRENT | MCL_FUTURE)) {
+	/* Bitrate/latency stats disabled by default */
+#ifdef RTE_LIBRTE_BITRATE
+	bitrate_enabled = 0;
+#endif
+#ifdef RTE_LIBRTE_LATENCY_STATS
+	latencystats_enabled = 0;
+#endif
+
+	argc -= diag;
+	argv += diag;
+	if (argc > 1)
+		launch_args_parse(argc, argv);
+
+	if (!no_mlockall && mlockall(MCL_CURRENT | MCL_FUTURE)) {
 		TESTPMD_LOG(NOTICE, "mlockall() failed with error \"%s\"\n",
 			strerror(errno));
 	}
@@ -2511,19 +2528,6 @@  main(int argc, char** argv)
 		rte_panic("Empty set of forwarding logical cores - check the "
 			  "core mask supplied in the command parameters\n");
 
-	/* Bitrate/latency stats disabled by default */
-#ifdef RTE_LIBRTE_BITRATE
-	bitrate_enabled = 0;
-#endif
-#ifdef RTE_LIBRTE_LATENCY_STATS
-	latencystats_enabled = 0;
-#endif
-
-	argc -= diag;
-	argv += diag;
-	if (argc > 1)
-		launch_args_parse(argc, argv);
-
 	if (tx_first && interactive)
 		rte_exit(EXIT_FAILURE, "--tx-first cannot be used on "
 				"interactive mode.\n");
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 153abea..028b873 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -319,6 +319,7 @@  extern volatile int test_done; /* stop packet forwarding when set to 1. */
 extern uint8_t lsc_interrupt; /**< disabled by "--no-lsc-interrupt" parameter */
 extern uint8_t rmv_interrupt; /**< disabled by "--no-rmv-interrupt" parameter */
 extern uint32_t event_print_mask;
+extern int no_mlockall; /**< set by "--no-mlockall" parameter */
 /**< set by "--print-event xxxx" and "--mask-event xxxx parameters */
 
 #ifdef RTE_LIBRTE_IXGBE_BYPASS