app/testpmd: make locking memory configurable

Add two new command-line parameters for either enabling or
disabling locking all memory at app startup.

Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Remy Horton <remy.horton@intel.com>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
This commit is contained in:
Anatoly Burakov 2018-05-03 13:38:19 +01:00 committed by Thomas Monjalon
parent 04db1d0da7
commit e505d84c64
4 changed files with 36 additions and 16 deletions

View File

@ -188,6 +188,8 @@ usage(char* progname)
printf(" --tx-offloads=0xXXXXXXXX: hexadecimal bitmask of TX queue offloads\n");
printf(" --hot-plug: enable hot plug for device.\n");
printf(" --vxlan-gpe-port=N: UPD port of tunnel VXLAN-GPE\n");
printf(" --mlockall: lock all memory\n");
printf(" --no-mlockall: do not lock all memory\n");
}
#ifdef RTE_LIBRTE_CMDLINE
@ -629,6 +631,8 @@ launch_args_parse(int argc, char** argv)
{ "tx-offloads", 1, 0, 0 },
{ "hot-plug", 0, 0, 0 },
{ "vxlan-gpe-port", 1, 0, 0 },
{ "mlockall", 0, 0, 0 },
{ "no-mlockall", 0, 0, 0 },
{ 0, 0, 0, 0 },
};
@ -1145,6 +1149,10 @@ launch_args_parse(int argc, char** argv)
}
if (!strcmp(lgopts[opt_idx].name, "hot-plug"))
hot_plug = 1;
if (!strcmp(lgopts[opt_idx].name, "mlockall"))
do_mlockall = 1;
if (!strcmp(lgopts[opt_idx].name, "no-mlockall"))
do_mlockall = 0;
break;
case 'h':
usage(argv[0]);

View File

@ -299,6 +299,10 @@ uint32_t event_print_mask = (UINT32_C(1) << RTE_ETH_EVENT_UNKNOWN) |
(UINT32_C(1) << RTE_ETH_EVENT_IPSEC) |
(UINT32_C(1) << RTE_ETH_EVENT_MACSEC) |
(UINT32_C(1) << RTE_ETH_EVENT_INTR_RMV);
/*
* Decide if all memory are locked for performance.
*/
int do_mlockall = 0;
/*
* NIC bypass mode configuration options.
@ -2603,7 +2607,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 (do_mlockall && mlockall(MCL_CURRENT | MCL_FUTURE)) {
TESTPMD_LOG(NOTICE, "mlockall() failed with error \"%s\"\n",
strerror(errno));
}
@ -2625,19 +2642,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");

View File

@ -334,9 +334,9 @@ 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 uint8_t hot_plug; /**< enable by "--hot-plug" parameter */
/**< set by "--print-event xxxx" and "--mask-event xxxx parameters */
extern uint8_t hot_plug; /**< enable by "--hot-plug" parameter */
extern int do_mlockall; /**< set by "--mlockall" or "--no-mlockall" parameter */
#ifdef RTE_LIBRTE_IXGBE_BYPASS
extern uint32_t bypass_timeout; /**< Store the NIC bypass watchdog timeout */

View File

@ -490,3 +490,11 @@ The commandline options are:
Set the UDP port number of tunnel VXLAN-GPE to N.
The default value is 4790.
* ``--mlockall``
Enable locking all memory.
* ``--no-mlockall``
Disable locking all memory.