DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ophir Munk <ophirmu@nvidia.com>
To: Ori Kam <orika@nvidia.com>,
	dev@dpdk.org, Raslan Darawsheh <rasland@nvidia.com>
Cc: Ophir Munk <ophirmu@nvidia.com>, Thomas Monjalon <thomas@monjalon.net>
Subject: [dpdk-dev] [PATCH v1 1/6] app/regex: move mem pool creation to worker routine
Date: Wed, 16 Dec 2020 16:49:26 +0000
Message-ID: <20201216164931.1517-2-ophirmu@nvidia.com> (raw)
In-Reply-To: <20201216164931.1517-1-ophirmu@nvidia.com>

Function rte_pktmbuf_pool_create() is moved from init_port() routine to
run_regex() routine. Looking forward on multi core support - init_port()
will be called only once as part of application startup while mem pool
creation should be called multiple times (per core).

Signed-off-by: Ophir Munk <ophirmu@nvidia.com>
---
 app/test-regex/main.c | 34 +++++++++++++++-------------------
 1 file changed, 15 insertions(+), 19 deletions(-)

diff --git a/app/test-regex/main.c b/app/test-regex/main.c
index ac6152d..cb2a065 100644
--- a/app/test-regex/main.c
+++ b/app/test-regex/main.c
@@ -163,8 +163,7 @@ read_file(char *file, char **buf)
 }
 
 static int
-init_port(struct rte_mempool **mbuf_mp, uint32_t nb_jobs,
-	  uint16_t *nb_max_payload, char *rules_file, uint8_t *nb_max_matches)
+init_port(uint16_t *nb_max_payload, char *rules_file, uint8_t *nb_max_matches)
 {
 	uint16_t id;
 	uint16_t num_devs;
@@ -187,14 +186,6 @@ init_port(struct rte_mempool **mbuf_mp, uint32_t nb_jobs,
 		return -EINVAL;
 	}
 
-	*mbuf_mp = rte_pktmbuf_pool_create("mbuf_pool", nb_jobs, 0,
-					  0, MBUF_SIZE, rte_socket_id());
-	if (*mbuf_mp == NULL) {
-		printf("Error, can't create memory pool\n");
-		res = -ENOMEM;
-		goto error;
-	}
-
 	rules_len = read_file(rules_file, &rules);
 	if (rules_len < 0) {
 		printf("Error, can't read rules files.\n");
@@ -237,8 +228,6 @@ init_port(struct rte_mempool **mbuf_mp, uint32_t nb_jobs,
 error:
 	if (rules)
 		rte_free(rules);
-	if (*mbuf_mp)
-		rte_mempool_free(*mbuf_mp);
 	return res;
 }
 
@@ -248,7 +237,7 @@ extbuf_free_cb(void *addr __rte_unused, void *fcb_opaque __rte_unused)
 }
 
 static int
-run_regex(struct rte_mempool *mbuf_mp, uint32_t nb_jobs,
+run_regex(uint32_t nb_jobs,
 	  uint16_t nb_max_payload, bool perf_mode, uint32_t nb_iterations,
 	  char *data_file, uint8_t nb_max_matches)
 {
@@ -273,9 +262,17 @@ run_regex(struct rte_mempool *mbuf_mp, uint32_t nb_jobs,
 	time_t end;
 	double time;
 	struct job_ctx *jobs_ctx;
+	struct rte_mempool *mbuf_mp;
 
 	shinfo.free_cb = extbuf_free_cb;
 
+	mbuf_mp = rte_pktmbuf_pool_create("mbuf_pool", nb_jobs, 0,
+			0, MBUF_SIZE, rte_socket_id());
+	if (mbuf_mp == NULL) {
+		printf("Error, can't create memory pool\n");
+		return -ENOMEM;
+	}
+
 	ops = rte_malloc(NULL, sizeof(*ops) * nb_jobs, 0);
 	if (!ops) {
 		printf("Error, can't allocate memory for ops.\n");
@@ -409,6 +406,9 @@ run_regex(struct rte_mempool *mbuf_mp, uint32_t nb_jobs,
 	rte_free(jobs_ctx);
 	if (buf)
 		rte_free(buf);
+	if (mbuf_mp)
+		rte_mempool_free(mbuf_mp);
+
 	return res;
 }
 
@@ -417,7 +417,6 @@ main(int argc, char **argv)
 {
 	char rules_file[MAX_FILE_NAME];
 	char data_file[MAX_FILE_NAME];
-	struct rte_mempool *mbuf_mp = NULL;
 	uint32_t nb_jobs = 0;
 	uint16_t nb_max_payload = 0;
 	bool perf_mode = 0;
@@ -434,16 +433,13 @@ main(int argc, char **argv)
 		args_parse(argc, argv, rules_file, data_file, &nb_jobs,
 			   &perf_mode, &nb_iterations);
 
-	ret = init_port(&mbuf_mp, nb_jobs, &nb_max_payload, rules_file,
-			&nb_max_matches);
+	ret = init_port(&nb_max_payload, rules_file, &nb_max_matches);
 	if (ret < 0)
 		rte_exit(EXIT_FAILURE, "init port failed\n");
-	ret = run_regex(mbuf_mp, nb_jobs, nb_max_payload, perf_mode,
+	ret = run_regex(nb_jobs, nb_max_payload, perf_mode,
 			nb_iterations, data_file, nb_max_matches);
 	if (ret < 0) {
-		rte_mempool_free(mbuf_mp);
 		rte_exit(EXIT_FAILURE, "RegEx function failed\n");
 	}
-	rte_mempool_free(mbuf_mp);
 	return EXIT_SUCCESS;
 }
-- 
2.8.4


  reply	other threads:[~2020-12-16 16:50 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-16 16:49 [dpdk-dev] [PATCH v1 0/6] regex multi Q with multi cores support Ophir Munk
2020-12-16 16:49 ` Ophir Munk [this message]
2020-12-20 10:41   ` [dpdk-dev] [PATCH v2 " Ophir Munk
2020-12-20 10:41     ` [dpdk-dev] [PATCH v2 1/6] app/regex: move mem pool creation to worker routine Ophir Munk
2021-01-10 11:10       ` [dpdk-dev] [PATCH v3 0/6] regex multi Q with multi cores support Ophir Munk
2021-01-10 11:10         ` [dpdk-dev] [PATCH v3 1/6] app/regex: move mem pool creation to worker routine Ophir Munk
2021-01-10 11:10         ` [dpdk-dev] [PATCH v3 2/6] app/regex: support multi QPs Ophir Munk
2021-01-10 11:10         ` [dpdk-dev] [PATCH v3 3/6] app/regex: read data file once at startup Ophir Munk
2021-01-10 11:10         ` [dpdk-dev] [PATCH v3 4/6] app/regex: support multi cores Ophir Munk
2021-01-10 11:10         ` [dpdk-dev] [PATCH v3 5/6] app/regex: support performance measurements per QP Ophir Munk
2021-01-10 11:10         ` [dpdk-dev] [PATCH v3 6/6] app/regex: replace Linux clock() API with rdtsc Ophir Munk
2021-01-12 23:05         ` [dpdk-dev] [PATCH v3 0/6] regex multi Q with multi cores support Thomas Monjalon
2020-12-20 10:41     ` [dpdk-dev] [PATCH v2 2/6] app/regex: support multi QPs Ophir Munk
2020-12-20 10:41     ` [dpdk-dev] [PATCH v2 3/6] app/regex: read data file once at startup Ophir Munk
2020-12-20 10:41     ` [dpdk-dev] [PATCH v2 4/6] app/regex: support multi cores Ophir Munk
2020-12-20 10:41     ` [dpdk-dev] [PATCH v2 5/6] app/regex: support performance measurements per QP Ophir Munk
2021-01-08  9:08       ` Thomas Monjalon
2021-01-10 11:16         ` Ophir Munk
2021-01-10 22:55           ` Thomas Monjalon
2021-01-11 19:07             ` David Christensen
2020-12-20 10:41     ` [dpdk-dev] [PATCH v2 6/6] app/regex: replace Linux clock() API with rdtsc Ophir Munk
2021-01-04 14:01     ` [dpdk-dev] [PATCH v2 0/6] regex multi Q with multi cores support Ori Kam
2020-12-16 16:49 ` [dpdk-dev] [PATCH v1 2/6] app/regex: support multi QPs Ophir Munk
2020-12-16 16:49 ` [dpdk-dev] [PATCH v1 3/6] app/regex: read data file once at startup Ophir Munk
2020-12-16 16:49 ` [dpdk-dev] [PATCH v1 4/6] app/regex: support multi cores Ophir Munk
2020-12-16 16:49 ` [dpdk-dev] [PATCH v1 5/6] app/regex: support performance measurements per QP Ophir Munk
2020-12-16 16:49 ` [dpdk-dev] [PATCH v1 6/6] app/regex: replace Linux clock() API with rdtsc Ophir Munk
2020-12-17 11:52 ` [dpdk-dev] [PATCH v1 0/6] regex multi Q with multi cores support Ori Kam

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201216164931.1517-2-ophirmu@nvidia.com \
    --to=ophirmu@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=orika@nvidia.com \
    --cc=rasland@nvidia.com \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git