DPDK patches and discussions
 help / color / mirror / Atom feed
From: Anatoly Burakov <anatoly.burakov@intel.com>
To: dev@dpdk.org
Cc: Olivier Matz <olivier.matz@6wind.com>, stable@dpdk.org
Subject: [dpdk-dev] [PATCH v4 4/6] test: fix memory leak in ring perf autotest
Date: Mon,  5 Feb 2018 13:03:10 +0000	[thread overview]
Message-ID: <a1c6aa73914c63cfd4cf72587a478ea8274bf3f6.1517834482.git.anatoly.burakov@intel.com> (raw)
In-Reply-To: <409be7970a029d2d2cfffeafee43ea2645244eb2.1517834482.git.anatoly.burakov@intel.com>
In-Reply-To: <8ccde502aee6921dd4fc74718309d60b8c82f444.1516178976.git.anatoly.burakov@intel.com>

Fixes: ac3fb3019c52 ("app: rework ring tests")
Cc: stable@dpdk.org

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Olivier Matz <olivier.matz@6wind.com>
---

Notes:
    v2: remove static ring variable

 test/test/test_ring_perf.c | 36 ++++++++++++++++++++----------------
 1 file changed, 20 insertions(+), 16 deletions(-)

diff --git a/test/test/test_ring_perf.c b/test/test/test_ring_perf.c
index 4363e4d..ebb3939 100644
--- a/test/test/test_ring_perf.c
+++ b/test/test/test_ring_perf.c
@@ -32,9 +32,6 @@
  */
 static const volatile unsigned bulk_sizes[] = { 8, 32 };
 
-/* The ring structure used for tests */
-static struct rte_ring *r;
-
 struct lcore_pair {
 	unsigned c1, c2;
 };
@@ -115,7 +112,7 @@ get_two_sockets(struct lcore_pair *lcp)
 
 /* Get cycle counts for dequeuing from an empty ring. Should be 2 or 3 cycles */
 static void
-test_empty_dequeue(void)
+test_empty_dequeue(struct rte_ring *r)
 {
 	const unsigned iter_shift = 26;
 	const unsigned iterations = 1<<iter_shift;
@@ -143,6 +140,7 @@ test_empty_dequeue(void)
  * and return two. Input = burst size, output = cycle average for sp/sc & mp/mc
  */
 struct thread_params {
+	struct rte_ring *r;
 	unsigned size;        /* input value, the burst size */
 	double spsc, mpmc;    /* output value, the single or multi timings */
 };
@@ -157,6 +155,7 @@ enqueue_bulk(void *p)
 	const unsigned iter_shift = 23;
 	const unsigned iterations = 1<<iter_shift;
 	struct thread_params *params = p;
+	struct rte_ring *r = params->r;
 	const unsigned size = params->size;
 	unsigned i;
 	void *burst[MAX_BURST] = {0};
@@ -192,6 +191,7 @@ dequeue_bulk(void *p)
 	const unsigned iter_shift = 23;
 	const unsigned iterations = 1<<iter_shift;
 	struct thread_params *params = p;
+	struct rte_ring *r = params->r;
 	const unsigned size = params->size;
 	unsigned i;
 	void *burst[MAX_BURST] = {0};
@@ -222,7 +222,7 @@ dequeue_bulk(void *p)
  * used to measure ring perf between hyperthreads, cores and sockets.
  */
 static void
-run_on_core_pair(struct lcore_pair *cores,
+run_on_core_pair(struct lcore_pair *cores, struct rte_ring *r,
 		lcore_function_t f1, lcore_function_t f2)
 {
 	struct thread_params param1 = {0}, param2 = {0};
@@ -230,6 +230,7 @@ run_on_core_pair(struct lcore_pair *cores,
 	for (i = 0; i < sizeof(bulk_sizes)/sizeof(bulk_sizes[0]); i++) {
 		lcore_count = 0;
 		param1.size = param2.size = bulk_sizes[i];
+		param1.r = param2.r = r;
 		if (cores->c1 == rte_get_master_lcore()) {
 			rte_eal_remote_launch(f2, &param2, cores->c2);
 			f1(&param1);
@@ -252,7 +253,7 @@ run_on_core_pair(struct lcore_pair *cores,
  * takes on a single lcore. Result is for comparison with the bulk enq+deq.
  */
 static void
-test_single_enqueue_dequeue(void)
+test_single_enqueue_dequeue(struct rte_ring *r)
 {
 	const unsigned iter_shift = 24;
 	const unsigned iterations = 1<<iter_shift;
@@ -285,7 +286,7 @@ test_single_enqueue_dequeue(void)
  * as for the bulk function called on a single lcore.
  */
 static void
-test_burst_enqueue_dequeue(void)
+test_burst_enqueue_dequeue(struct rte_ring *r)
 {
 	const unsigned iter_shift = 23;
 	const unsigned iterations = 1<<iter_shift;
@@ -323,7 +324,7 @@ test_burst_enqueue_dequeue(void)
 
 /* Times enqueue and dequeue on a single lcore */
 static void
-test_bulk_enqueue_dequeue(void)
+test_bulk_enqueue_dequeue(struct rte_ring *r)
 {
 	const unsigned iter_shift = 23;
 	const unsigned iterations = 1<<iter_shift;
@@ -365,32 +366,35 @@ static int
 test_ring_perf(void)
 {
 	struct lcore_pair cores;
+	struct rte_ring *r = NULL;
+
 	r = rte_ring_create(RING_NAME, RING_SIZE, rte_socket_id(), 0);
-	if (r == NULL && (r = rte_ring_lookup(RING_NAME)) == NULL)
+	if (r == NULL)
 		return -1;
 
 	printf("### Testing single element and burst enq/deq ###\n");
-	test_single_enqueue_dequeue();
-	test_burst_enqueue_dequeue();
+	test_single_enqueue_dequeue(r);
+	test_burst_enqueue_dequeue(r);
 
 	printf("\n### Testing empty dequeue ###\n");
-	test_empty_dequeue();
+	test_empty_dequeue(r);
 
 	printf("\n### Testing using a single lcore ###\n");
-	test_bulk_enqueue_dequeue();
+	test_bulk_enqueue_dequeue(r);
 
 	if (get_two_hyperthreads(&cores) == 0) {
 		printf("\n### Testing using two hyperthreads ###\n");
-		run_on_core_pair(&cores, enqueue_bulk, dequeue_bulk);
+		run_on_core_pair(&cores, r, enqueue_bulk, dequeue_bulk);
 	}
 	if (get_two_cores(&cores) == 0) {
 		printf("\n### Testing using two physical cores ###\n");
-		run_on_core_pair(&cores, enqueue_bulk, dequeue_bulk);
+		run_on_core_pair(&cores, r, enqueue_bulk, dequeue_bulk);
 	}
 	if (get_two_sockets(&cores) == 0) {
 		printf("\n### Testing using two NUMA nodes ###\n");
-		run_on_core_pair(&cores, enqueue_bulk, dequeue_bulk);
+		run_on_core_pair(&cores, r, enqueue_bulk, dequeue_bulk);
 	}
+	rte_ring_free(r);
 	return 0;
 }
 
-- 
2.7.4

  parent reply	other threads:[~2018-02-05 13:03 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-22 10:12 [dpdk-dev] [PATCH 1/6] test: fix memory leak in bitmap test Anatoly Burakov
2017-12-22 10:12 ` [dpdk-dev] [PATCH 2/6] test: fix memory leak in reorder autotest Anatoly Burakov
2017-12-22 10:12 ` [dpdk-dev] [PATCH 3/6] test: fix memory leak in ring autotest Anatoly Burakov
2017-12-22 16:26   ` Olivier MATZ
2017-12-23 11:49     ` Burakov, Anatoly
2017-12-22 10:12 ` [dpdk-dev] [PATCH 4/6] test: fix memory leak in ring perf autotest Anatoly Burakov
2017-12-22 16:28   ` Olivier MATZ
2017-12-22 10:12 ` [dpdk-dev] [PATCH 5/6] test: fix memory leak in table autotest Anatoly Burakov
2018-01-11 14:17   ` Dumitrescu, Cristian
2017-12-22 10:12 ` [dpdk-dev] [PATCH 6/6] test: fix memory leak in timer perf autotest Anatoly Burakov
2018-01-11 14:16 ` [dpdk-dev] [PATCH 1/6] test: fix memory leak in bitmap test Dumitrescu, Cristian
2018-01-17  8:36 ` [dpdk-dev] [PATCH v2 " Anatoly Burakov
2018-01-17  8:36 ` [dpdk-dev] [PATCH v2 2/6] test: fix memory leak in reorder autotest Anatoly Burakov
2018-01-17  8:36 ` [dpdk-dev] [PATCH v2 3/6] test: fix memory leak in ring autotest Anatoly Burakov
2018-01-17  8:42   ` Burakov, Anatoly
2018-01-17  8:36 ` [dpdk-dev] [PATCH v2 4/6] test: fix memory leak in ring perf autotest Anatoly Burakov
2018-01-17  8:36 ` [dpdk-dev] [PATCH v2 5/6] test: fix memory leak in table autotest Anatoly Burakov
2018-01-17  8:36 ` [dpdk-dev] [PATCH v2 6/6] test: fix memory leak in timer perf autotest Anatoly Burakov
2018-01-17 11:15 ` [dpdk-dev] [PATCH v3 1/6] test: fix memory leak in bitmap test Anatoly Burakov
2018-02-01  0:10   ` Thomas Monjalon
2018-02-01 17:04     ` Burakov, Anatoly
2018-02-02  9:08       ` Thomas Monjalon
2018-02-02 10:31         ` Burakov, Anatoly
2018-02-02 17:08           ` Thomas Monjalon
2018-02-05 10:06             ` Burakov, Anatoly
2018-02-05 10:25               ` Thomas Monjalon
2018-02-05 13:03   ` [dpdk-dev] [PATCH v4 " Anatoly Burakov
2018-02-06 13:35     ` [dpdk-dev] [PATCH v5 " Anatoly Burakov
2018-02-06 18:34       ` Thomas Monjalon
2018-02-06 13:35     ` [dpdk-dev] [PATCH v5 2/6] test: fix memory leak in reorder autotest Anatoly Burakov
2018-02-06 13:35     ` [dpdk-dev] [PATCH v5 3/6] test: fix memory leak in ring autotest Anatoly Burakov
2018-02-06 13:35     ` [dpdk-dev] [PATCH v5 4/6] test: fix memory leak in ring perf autotest Anatoly Burakov
2018-02-06 13:35     ` [dpdk-dev] [PATCH v5 5/6] test: fix memory leak in table autotest Anatoly Burakov
2018-02-06 13:35     ` [dpdk-dev] [PATCH v5 6/6] test: fix memory leak in timer perf autotest Anatoly Burakov
2018-02-05 13:03   ` [dpdk-dev] [PATCH v4 2/6] test: fix memory leak in reorder autotest Anatoly Burakov
2018-02-05 13:03   ` [dpdk-dev] [PATCH v4 3/6] test: fix memory leak in ring autotest Anatoly Burakov
2018-02-06  0:36     ` Thomas Monjalon
2018-02-05 13:03   ` Anatoly Burakov [this message]
2018-02-05 13:03   ` [dpdk-dev] [PATCH v4 5/6] test: fix memory leak in table autotest Anatoly Burakov
2018-02-05 13:03   ` [dpdk-dev] [PATCH v4 6/6] test: fix memory leak in timer perf autotest Anatoly Burakov
2018-01-17 11:15 ` [dpdk-dev] [PATCH v3 2/6] test: fix memory leak in reorder autotest Anatoly Burakov
2018-01-17 11:15 ` [dpdk-dev] [PATCH v3 3/6] test: fix memory leak in ring autotest Anatoly Burakov
2018-01-19  8:33   ` Olivier Matz
2018-01-17 11:15 ` [dpdk-dev] [PATCH v3 4/6] test: fix memory leak in ring perf autotest Anatoly Burakov
2018-01-19  8:35   ` Olivier Matz
2018-01-17 11:15 ` [dpdk-dev] [PATCH v3 5/6] test: fix memory leak in table autotest Anatoly Burakov
2018-01-17 11:15 ` [dpdk-dev] [PATCH v3 6/6] test: fix memory leak in timer perf autotest Anatoly Burakov

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=a1c6aa73914c63cfd4cf72587a478ea8274bf3f6.1517834482.git.anatoly.burakov@intel.com \
    --to=anatoly.burakov@intel.com \
    --cc=dev@dpdk.org \
    --cc=olivier.matz@6wind.com \
    --cc=stable@dpdk.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).