[dpdk-dev] [PATCH v2 13/15] examples/eventdev: add mempool size configuration

Pavan Nikhilesh pbhagavatula at caviumnetworks.com
Wed Jan 10 12:10:11 CET 2018


Add option to configure the mempool size at run time instead of
hardcoding it to 16384 * num_ports.

Signed-off-by: Pavan Nikhilesh <pbhagavatula at caviumnetworks.com>
---
 examples/eventdev_pipeline_sw_pmd/main.c            | 12 ++++++++++--
 examples/eventdev_pipeline_sw_pmd/pipeline_common.h |  1 +
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/examples/eventdev_pipeline_sw_pmd/main.c b/examples/eventdev_pipeline_sw_pmd/main.c
index 2c7b02b86..bf2a04edb 100644
--- a/examples/eventdev_pipeline_sw_pmd/main.c
+++ b/examples/eventdev_pipeline_sw_pmd/main.c
@@ -144,6 +144,7 @@ static struct option long_options[] = {
 	{"sched-mask", required_argument, 0, 'e'},
 	{"cq-depth", required_argument, 0, 'c'},
 	{"work-cycles", required_argument, 0, 'W'},
+	{"mempool-size", required_argument, 0, 'm'},
 	{"queue-priority", no_argument, 0, 'P'},
 	{"parallel", no_argument, 0, 'p'},
 	{"ordered", no_argument, 0, 'o'},
@@ -173,6 +174,7 @@ usage(void)
 		"  -p, --parallel               Use parallel scheduling\n"
 		"  -q, --quiet                  Minimize printed output\n"
 		"  -a, --use-atq                Use all type queues\n"
+		"  -m, --mempool-size=N         Dictate the mempool size\n"
 		"  -D, --dump                   Print detailed statistics before exit"
 		"\n";
 	fprintf(stderr, "%s", usage_str);
@@ -193,7 +195,7 @@ parse_app_args(int argc, char **argv)
 	int i;
 
 	for (;;) {
-		c = getopt_long(argc, argv, "r:t:e:c:w:n:f:s:paoPqDW:",
+		c = getopt_long(argc, argv, "r:t:e:c:w:n:f:s:m:paoPqDW:",
 				long_options, &option_index);
 		if (c == -1)
 			break;
@@ -253,6 +255,9 @@ parse_app_args(int argc, char **argv)
 			popcnt = __builtin_popcountll(sched_lcore_mask);
 			fdata->sched_single = (popcnt == 1);
 			break;
+		case 'm':
+			cdata.num_mbuf = (uint64_t)atol(optarg);
+			break;
 		default:
 			usage();
 		}
@@ -356,8 +361,11 @@ init_ports(unsigned int num_ports)
 	uint8_t portid;
 	unsigned int i;
 
+	if (!cdata.num_mbuf)
+		cdata.num_mbuf = 16384 * num_ports;
+
 	struct rte_mempool *mp = rte_pktmbuf_pool_create("packet_pool",
-			/* mbufs */ 16384 * num_ports,
+			/* mbufs */ cdata.num_mbuf,
 			/* cache_size */ 512,
 			/* priv_size*/ 0,
 			/* data_room_size */ RTE_MBUF_DEFAULT_BUF_SIZE,
diff --git a/examples/eventdev_pipeline_sw_pmd/pipeline_common.h b/examples/eventdev_pipeline_sw_pmd/pipeline_common.h
index 66553038c..9703396f8 100644
--- a/examples/eventdev_pipeline_sw_pmd/pipeline_common.h
+++ b/examples/eventdev_pipeline_sw_pmd/pipeline_common.h
@@ -70,6 +70,7 @@ struct config_data {
 	unsigned int active_cores;
 	unsigned int num_workers;
 	int64_t num_packets;
+	uint64_t num_mbuf;
 	unsigned int num_fids;
 	int queue_type;
 	int worker_cycles;
-- 
2.15.1



More information about the dev mailing list