DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 1/6] test: fix memory leak in bitmap test
@ 2017-12-22 10:12 Anatoly Burakov
  2017-12-22 10:12 ` [dpdk-dev] [PATCH 2/6] test: fix memory leak in reorder autotest Anatoly Burakov
                   ` (17 more replies)
  0 siblings, 18 replies; 47+ messages in thread
From: Anatoly Burakov @ 2017-12-22 10:12 UTC (permalink / raw)
  To: dev; +Cc: Cristian Dumitrescu, pbhagavatula

Fixes: c7e4a134e769 ("test: verify bitmap operations")
Cc: pbhagavatula@caviumnetworks.com
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 test/test/test_bitmap.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/test/test/test_bitmap.c b/test/test/test_bitmap.c
index 5c9eee9..7045d33 100644
--- a/test/test/test_bitmap.c
+++ b/test/test/test_bitmap.c
@@ -186,6 +186,9 @@ test_bitmap(void)
 	if (test_bitmap_scan_operations(bmp) < 0)
 		return TEST_FAILED;
 
+	rte_bitmap_free(bmp);
+	rte_free(mem);
+
 	return TEST_SUCCESS;
 }
 
-- 
2.7.4

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [dpdk-dev] [PATCH 2/6] test: fix memory leak in reorder autotest
  2017-12-22 10:12 [dpdk-dev] [PATCH 1/6] test: fix memory leak in bitmap test Anatoly Burakov
@ 2017-12-22 10:12 ` Anatoly Burakov
  2017-12-22 10:12 ` [dpdk-dev] [PATCH 3/6] test: fix memory leak in ring autotest Anatoly Burakov
                   ` (16 subsequent siblings)
  17 siblings, 0 replies; 47+ messages in thread
From: Anatoly Burakov @ 2017-12-22 10:12 UTC (permalink / raw)
  To: dev; +Cc: Reshma Pattan, sergio.gonzalez.monroy, reshma.pattan, stable

Add a teardown function that frees allocated resources.

Fixes: d0c9b58d7156 ("app/test: new reorder unit test")
Cc: sergio.gonzalez.monroy@intel.com
Cc: reshma.pattan@intek.com
Cc: stable@dpdk.org
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 test/test/test_reorder.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/test/test/test_reorder.c b/test/test/test_reorder.c
index 4ec22ac..429f6eb4 100644
--- a/test/test/test_reorder.c
+++ b/test/test/test_reorder.c
@@ -360,9 +360,20 @@ test_setup(void)
 	return 0;
 }
 
+static void
+test_teardown(void)
+{
+	rte_reorder_free(test_params->b);
+	test_params->b = NULL;
+	rte_mempool_free(test_params->p);
+	test_params->p = NULL;
+}
+
+
 static struct unit_test_suite reorder_test_suite  = {
 
 	.setup = test_setup,
+	.teardown = test_teardown,
 	.suite_name = "Reorder Unit Test Suite",
 	.unit_test_cases = {
 		TEST_CASE(test_reorder_create),
-- 
2.7.4

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [dpdk-dev] [PATCH 3/6] test: fix memory leak in ring autotest
  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 ` Anatoly Burakov
  2017-12-22 16:26   ` Olivier MATZ
  2017-12-22 10:12 ` [dpdk-dev] [PATCH 4/6] test: fix memory leak in ring perf autotest Anatoly Burakov
                   ` (15 subsequent siblings)
  17 siblings, 1 reply; 47+ messages in thread
From: Anatoly Burakov @ 2017-12-22 10:12 UTC (permalink / raw)
  To: dev; +Cc: Olivier Matz, stable

Fixes: af75078fece3 ("first public release")
Cc: stable@dpdk.org
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 test/test/test_ring.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/test/test/test_ring.c b/test/test/test_ring.c
index 5eb40a0..004d67e 100644
--- a/test/test/test_ring.c
+++ b/test/test/test_ring.c
@@ -760,6 +760,7 @@ test_ring_basic_ex(void)
 
 	ret = 0;
 fail_test:
+	rte_ring_free(rp);
 	if (obj != NULL)
 		rte_free(obj);
 
@@ -894,6 +895,8 @@ test_ring(void)
 	/* dump the ring status */
 	rte_ring_list_dump(stdout);
 
+	rte_ring_free(r);
+
 	return 0;
 }
 
-- 
2.7.4

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [dpdk-dev] [PATCH 4/6] test: fix memory leak in ring perf autotest
  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 10:12 ` 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
                   ` (14 subsequent siblings)
  17 siblings, 1 reply; 47+ messages in thread
From: Anatoly Burakov @ 2017-12-22 10:12 UTC (permalink / raw)
  To: dev; +Cc: Olivier Matz, stable

Fixes: ac3fb3019c52 ("app: rework ring tests")
Cc: stable@dpdk.org
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 test/test/test_ring_perf.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/test/test/test_ring_perf.c b/test/test/test_ring_perf.c
index 84d2003..b586459 100644
--- a/test/test/test_ring_perf.c
+++ b/test/test/test_ring_perf.c
@@ -420,6 +420,7 @@ test_ring_perf(void)
 		printf("\n### Testing using two NUMA nodes ###\n");
 		run_on_core_pair(&cores, enqueue_bulk, dequeue_bulk);
 	}
+	rte_ring_free(r);
 	return 0;
 }
 
-- 
2.7.4

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [dpdk-dev] [PATCH 5/6] test: fix memory leak in table autotest
  2017-12-22 10:12 [dpdk-dev] [PATCH 1/6] test: fix memory leak in bitmap test Anatoly Burakov
                   ` (2 preceding siblings ...)
  2017-12-22 10:12 ` [dpdk-dev] [PATCH 4/6] test: fix memory leak in ring perf autotest Anatoly Burakov
@ 2017-12-22 10:12 ` 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
                   ` (13 subsequent siblings)
  17 siblings, 1 reply; 47+ messages in thread
From: Anatoly Burakov @ 2017-12-22 10:12 UTC (permalink / raw)
  To: dev; +Cc: Cristian Dumitrescu, stable

Always deallocate allocated resources after the test is done.

Fixes: 5205954791cb ("app/test: packet framework unit tests")
Cc: cristian.dumitrescu@intel.com
Cc: stable@dpdk.org
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 test/test/test_table.c | 44 ++++++++++++++++++++++++++++----------------
 1 file changed, 28 insertions(+), 16 deletions(-)

diff --git a/test/test/test_table.c b/test/test/test_table.c
index db7d4e6..c5a6e00 100644
--- a/test/test/test_table.c
+++ b/test/test/test_table.c
@@ -84,6 +84,14 @@ uint64_t pipeline_test_hash(void *key,
 }
 
 static void
+app_free_resources(void) {
+	int i;
+	for (i = 0; i < N_PORTS; i++)
+		rte_ring_free(rings_rx[i]);
+	rte_mempool_free(pool);
+}
+
+static void
 app_init_mbuf_pools(void)
 {
 	/* Init the buffer pool */
@@ -142,18 +150,20 @@ app_init_rings(void)
 static int
 test_table(void)
 {
-	int status, failures;
+	int status, ret;
 	unsigned i;
 
-	failures = 0;
+	ret = TEST_SUCCESS;
 
 	app_init_rings();
 	app_init_mbuf_pools();
 
 	printf("\n\n\n\n************Pipeline tests************\n");
 
-	if (test_table_pipeline() < 0)
-		return -1;
+	if (test_table_pipeline() < 0) {
+		ret = TEST_FAILED;
+		goto end;
+	}
 
 	printf("\n\n\n\n************Port tests************\n");
 	for (i = 0; i < n_port_tests; i++) {
@@ -161,8 +171,8 @@ test_table(void)
 		if (status < 0) {
 			printf("\nPort test number %d failed (%d).\n", i,
 				status);
-			failures++;
-			return -1;
+			ret = TEST_FAILED;
+			goto end;
 		}
 	}
 
@@ -172,8 +182,8 @@ test_table(void)
 		if (status < 0) {
 			printf("\nTable test number %d failed (%d).\n", i,
 				status);
-			failures++;
-			return -1;
+			ret = TEST_FAILED;
+			goto end;
 		}
 	}
 
@@ -183,21 +193,23 @@ test_table(void)
 		if (status < 0) {
 			printf("\nCombined table test number %d failed with "
 				"reason number %d.\n", i, status);
-			failures++;
-			return -1;
+			ret = TEST_FAILED;
+			goto end;
 		}
 	}
 
-	if (failures)
-		return -1;
-
 #ifdef RTE_LIBRTE_ACL
 	printf("\n\n\n\n************ACL tests************\n");
-	if (test_table_acl() < 0)
-		return -1;
+	if (test_table_acl() < 0) {
+		ret = TEST_FAILED;
+		goto end;
+	}
 #endif
 
-	return 0;
+end:
+	app_free_resources();
+
+	return ret;
 }
 
 REGISTER_TEST_COMMAND(table_autotest, test_table);
-- 
2.7.4

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [dpdk-dev] [PATCH 6/6] test: fix memory leak in timer perf autotest
  2017-12-22 10:12 [dpdk-dev] [PATCH 1/6] test: fix memory leak in bitmap test Anatoly Burakov
                   ` (3 preceding siblings ...)
  2017-12-22 10:12 ` [dpdk-dev] [PATCH 5/6] test: fix memory leak in table autotest Anatoly Burakov
@ 2017-12-22 10:12 ` Anatoly Burakov
  2018-01-11 14:16 ` [dpdk-dev] [PATCH 1/6] test: fix memory leak in bitmap test Dumitrescu, Cristian
                   ` (12 subsequent siblings)
  17 siblings, 0 replies; 47+ messages in thread
From: Anatoly Burakov @ 2017-12-22 10:12 UTC (permalink / raw)
  To: dev; +Cc: Robert Sanford, stable

Fixes: 277afaf3dbcb ("app/test: add timer_perf")
Cc: stable@dpdk.org
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 test/test/test_timer_perf.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/test/test/test_timer_perf.c b/test/test/test_timer_perf.c
index 467ae13..9804133 100644
--- a/test/test/test_timer_perf.c
+++ b/test/test/test_timer_perf.c
@@ -156,6 +156,7 @@ test_timer_perf(void)
 	printf("Time per rte_timer_manage with zero callbacks: %"PRIu64" cycles\n",
 			(end_tsc - start_tsc + iterations/2) / iterations);
 
+	rte_free(tms);
 	return 0;
 }
 
-- 
2.7.4

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [dpdk-dev] [PATCH 3/6] test: fix memory leak in ring autotest
  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
  0 siblings, 1 reply; 47+ messages in thread
From: Olivier MATZ @ 2017-12-22 16:26 UTC (permalink / raw)
  To: Anatoly Burakov; +Cc: dev, stable

Hi,

On Fri, Dec 22, 2017 at 10:12:07AM +0000, Anatoly Burakov wrote:
> Fixes: af75078fece3 ("first public release")

Not sure about this commit id: freeing rings is only possible
since commit 4e32101f9b01 ("ring: support freeing").

[...]

> @@ -894,6 +895,8 @@ test_ring(void)
>  	/* dump the ring status */
>  	rte_ring_list_dump(stdout);
>  
> +	rte_ring_free(r);
> +
>  	return 0;

I think this is incorrect: r is a static variable, and if it is
not set to NULL, it will be reused at next call.

Ideally, removing the static variable would be better than just
resetting the value to NULL, but it will require more modifications:
add a ring argument to test function, and change return -1 -> goto fail.

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [dpdk-dev] [PATCH 4/6] test: fix memory leak in ring perf autotest
  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
  0 siblings, 0 replies; 47+ messages in thread
From: Olivier MATZ @ 2017-12-22 16:28 UTC (permalink / raw)
  To: Anatoly Burakov; +Cc: dev, stable

On Fri, Dec 22, 2017 at 10:12:08AM +0000, Anatoly Burakov wrote:
> Fixes: ac3fb3019c52 ("app: rework ring tests")
> Cc: stable@dpdk.org
> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
> ---
>  test/test/test_ring_perf.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/test/test/test_ring_perf.c b/test/test/test_ring_perf.c
> index 84d2003..b586459 100644
> --- a/test/test/test_ring_perf.c
> +++ b/test/test/test_ring_perf.c
> @@ -420,6 +420,7 @@ test_ring_perf(void)
>  		printf("\n### Testing using two NUMA nodes ###\n");
>  		run_on_core_pair(&cores, enqueue_bulk, dequeue_bulk);
>  	}
> +	rte_ring_free(r);
>  	return 0;
>  }

Same comment than the functional ring test, r is static.

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [dpdk-dev] [PATCH 3/6] test: fix memory leak in ring autotest
  2017-12-22 16:26   ` Olivier MATZ
@ 2017-12-23 11:49     ` Burakov, Anatoly
  0 siblings, 0 replies; 47+ messages in thread
From: Burakov, Anatoly @ 2017-12-23 11:49 UTC (permalink / raw)
  To: Olivier MATZ; +Cc: dev, stable

On 22-Dec-17 4:26 PM, Olivier MATZ wrote:
> Hi,
> 
> On Fri, Dec 22, 2017 at 10:12:07AM +0000, Anatoly Burakov wrote:
>> Fixes: af75078fece3 ("first public release")
> 
> Not sure about this commit id: freeing rings is only possible
> since commit 4e32101f9b01 ("ring: support freeing").

You're correct, i'll fix it in v2.

> 
> [...]
> 
>> @@ -894,6 +895,8 @@ test_ring(void)
>>   	/* dump the ring status */
>>   	rte_ring_list_dump(stdout);
>>   
>> +	rte_ring_free(r);
>> +
>>   	return 0;
> 
> I think this is incorrect: r is a static variable, and if it is
> not set to NULL, it will be reused at next call.

The point of these changes is not to leave any memory allocated after 
the test is done, regardless of whether it will be reused again.

> 
> Ideally, removing the static variable would be better than just
> resetting the value to NULL, but it will require more modifications:
> add a ring argument to test function, and change return -1 -> goto fail.
> 

...or rewrite it with the testsuite and do proper setup and teardown :) 
Anyway, i'll implement the suggestion in v2.

-- 
Thanks,
Anatoly

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [dpdk-dev] [PATCH 1/6] test: fix memory leak in bitmap test
  2017-12-22 10:12 [dpdk-dev] [PATCH 1/6] test: fix memory leak in bitmap test Anatoly Burakov
                   ` (4 preceding siblings ...)
  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 ` Dumitrescu, Cristian
  2018-01-17  8:36 ` [dpdk-dev] [PATCH v2 " Anatoly Burakov
                   ` (11 subsequent siblings)
  17 siblings, 0 replies; 47+ messages in thread
From: Dumitrescu, Cristian @ 2018-01-11 14:16 UTC (permalink / raw)
  To: Burakov, Anatoly, dev; +Cc: pbhagavatula



> -----Original Message-----
> From: Burakov, Anatoly
> Sent: Friday, December 22, 2017 10:12 AM
> To: dev@dpdk.org
> Cc: Dumitrescu, Cristian <cristian.dumitrescu@intel.com>;
> pbhagavatula@caviumnetworks.com
> Subject: [PATCH 1/6] test: fix memory leak in bitmap test
> 
> Fixes: c7e4a134e769 ("test: verify bitmap operations")
> Cc: pbhagavatula@caviumnetworks.com
> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
> ---
>  test/test/test_bitmap.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/test/test/test_bitmap.c b/test/test/test_bitmap.c
> index 5c9eee9..7045d33 100644
> --- a/test/test/test_bitmap.c
> +++ b/test/test/test_bitmap.c
> @@ -186,6 +186,9 @@ test_bitmap(void)
>  	if (test_bitmap_scan_operations(bmp) < 0)
>  		return TEST_FAILED;
> 
> +	rte_bitmap_free(bmp);
> +	rte_free(mem);
> +
>  	return TEST_SUCCESS;
>  }
> 
> --
> 2.7.4

Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [dpdk-dev] [PATCH 5/6] test: fix memory leak in table autotest
  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
  0 siblings, 0 replies; 47+ messages in thread
From: Dumitrescu, Cristian @ 2018-01-11 14:17 UTC (permalink / raw)
  To: Burakov, Anatoly, dev; +Cc: stable



> -----Original Message-----
> From: Burakov, Anatoly
> Sent: Friday, December 22, 2017 10:12 AM
> To: dev@dpdk.org
> Cc: Dumitrescu, Cristian <cristian.dumitrescu@intel.com>; stable@dpdk.org
> Subject: [PATCH 5/6] test: fix memory leak in table autotest
> 
> Always deallocate allocated resources after the test is done.
> 
> Fixes: 5205954791cb ("app/test: packet framework unit tests")
> Cc: cristian.dumitrescu@intel.com
> Cc: stable@dpdk.org
> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
> ---
>  test/test/test_table.c | 44 ++++++++++++++++++++++++++++----------------
>  1 file changed, 28 insertions(+), 16 deletions(-)
> 
> diff --git a/test/test/test_table.c b/test/test/test_table.c


Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [dpdk-dev] [PATCH v2 1/6] test: fix memory leak in bitmap test
  2017-12-22 10:12 [dpdk-dev] [PATCH 1/6] test: fix memory leak in bitmap test Anatoly Burakov
                   ` (5 preceding siblings ...)
  2018-01-11 14:16 ` [dpdk-dev] [PATCH 1/6] test: fix memory leak in bitmap test Dumitrescu, Cristian
@ 2018-01-17  8:36 ` Anatoly Burakov
  2018-01-17  8:36 ` [dpdk-dev] [PATCH v2 2/6] test: fix memory leak in reorder autotest Anatoly Burakov
                   ` (10 subsequent siblings)
  17 siblings, 0 replies; 47+ messages in thread
From: Anatoly Burakov @ 2018-01-17  8:36 UTC (permalink / raw)
  To: dev; +Cc: Cristian Dumitrescu, pbhagavatula

Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>

Fixes: c7e4a134e769 ("test: verify bitmap operations")
Cc: pbhagavatula@caviumnetworks.com

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 test/test/test_bitmap.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/test/test/test_bitmap.c b/test/test/test_bitmap.c
index 05d547e..c3169e9 100644
--- a/test/test/test_bitmap.c
+++ b/test/test/test_bitmap.c
@@ -158,6 +158,9 @@ test_bitmap(void)
 	if (test_bitmap_scan_operations(bmp) < 0)
 		return TEST_FAILED;
 
+	rte_bitmap_free(bmp);
+	rte_free(mem);
+
 	return TEST_SUCCESS;
 }
 
-- 
2.7.4

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [dpdk-dev] [PATCH v2 2/6] test: fix memory leak in reorder autotest
  2017-12-22 10:12 [dpdk-dev] [PATCH 1/6] test: fix memory leak in bitmap test Anatoly Burakov
                   ` (6 preceding siblings ...)
  2018-01-17  8:36 ` [dpdk-dev] [PATCH v2 " Anatoly Burakov
@ 2018-01-17  8:36 ` Anatoly Burakov
  2018-01-17  8:36 ` [dpdk-dev] [PATCH v2 3/6] test: fix memory leak in ring autotest Anatoly Burakov
                   ` (9 subsequent siblings)
  17 siblings, 0 replies; 47+ messages in thread
From: Anatoly Burakov @ 2018-01-17  8:36 UTC (permalink / raw)
  To: dev; +Cc: Reshma Pattan, sergio.gonzalez.monroy, reshma.pattan, stable

Add a teardown function that frees allocated resources.

Fixes: d0c9b58d7156 ("app/test: new reorder unit test")
Cc: sergio.gonzalez.monroy@intel.com
Cc: reshma.pattan@intek.com
Cc: stable@dpdk.org

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 test/test/test_reorder.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/test/test/test_reorder.c b/test/test/test_reorder.c
index e834bac..65e4f38 100644
--- a/test/test/test_reorder.c
+++ b/test/test/test_reorder.c
@@ -331,9 +331,20 @@ test_setup(void)
 	return 0;
 }
 
+static void
+test_teardown(void)
+{
+	rte_reorder_free(test_params->b);
+	test_params->b = NULL;
+	rte_mempool_free(test_params->p);
+	test_params->p = NULL;
+}
+
+
 static struct unit_test_suite reorder_test_suite  = {
 
 	.setup = test_setup,
+	.teardown = test_teardown,
 	.suite_name = "Reorder Unit Test Suite",
 	.unit_test_cases = {
 		TEST_CASE(test_reorder_create),
-- 
2.7.4

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [dpdk-dev] [PATCH v2 3/6] test: fix memory leak in ring autotest
  2017-12-22 10:12 [dpdk-dev] [PATCH 1/6] test: fix memory leak in bitmap test Anatoly Burakov
                   ` (7 preceding siblings ...)
  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 ` 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
                   ` (8 subsequent siblings)
  17 siblings, 1 reply; 47+ messages in thread
From: Anatoly Burakov @ 2018-01-17  8:36 UTC (permalink / raw)
  To: dev; +Cc: Olivier Matz, stable

Get rid of global static ring variable and don't reuse rings
between test runs.

Fixes: af75078fece3 ("first public release")
Cc: stable@dpdk.org

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 test/test/test_ring.c | 61 ++++++++++++++++++++++++++++-----------------------
 1 file changed, 33 insertions(+), 28 deletions(-)

diff --git a/test/test/test_ring.c b/test/test/test_ring.c
index 19d497a..b339f04 100644
--- a/test/test/test_ring.c
+++ b/test/test/test_ring.c
@@ -57,8 +57,6 @@
 
 static rte_atomic32_t synchro;
 
-static struct rte_ring *r;
-
 #define	TEST_RING_VERIFY(exp)						\
 	if (!(exp)) {							\
 		printf("error at %s:%d\tcondition " #exp " failed\n",	\
@@ -73,7 +71,7 @@ static struct rte_ring *r;
  * helper routine for test_ring_basic
  */
 static int
-test_ring_basic_full_empty(void * const src[], void *dst[])
+test_ring_basic_full_empty(struct rte_ring *r, void * const src[], void *dst[])
 {
 	unsigned i, rand;
 	const unsigned rsz = RING_SIZE - 1;
@@ -114,7 +112,7 @@ test_ring_basic_full_empty(void * const src[], void *dst[])
 }
 
 static int
-test_ring_basic(void)
+test_ring_basic(struct rte_ring *r)
 {
 	void **src = NULL, **cur_src = NULL, **dst = NULL, **cur_dst = NULL;
 	int ret;
@@ -250,7 +248,7 @@ test_ring_basic(void)
 		goto fail;
 	}
 
-	if (test_ring_basic_full_empty(src, dst) != 0)
+	if (test_ring_basic_full_empty(r, src, dst) != 0)
 		goto fail;
 
 	cur_src = src;
@@ -317,7 +315,7 @@ test_ring_basic(void)
 }
 
 static int
-test_ring_burst_basic(void)
+test_ring_burst_basic(struct rte_ring *r)
 {
 	void **src = NULL, **cur_src = NULL, **dst = NULL, **cur_dst = NULL;
 	int ret;
@@ -731,6 +729,7 @@ test_ring_basic_ex(void)
 
 	ret = 0;
 fail_test:
+	rte_ring_free(rp);
 	if (obj != NULL)
 		rte_free(obj);
 
@@ -811,61 +810,67 @@ test_ring_with_exact_size(void)
 static int
 test_ring(void)
 {
+	struct rte_ring *r = NULL;
+
 	/* some more basic operations */
 	if (test_ring_basic_ex() < 0)
-		return -1;
+		goto test_fail;
 
 	rte_atomic32_init(&synchro);
 
+	r = rte_ring_create("test", RING_SIZE, SOCKET_ID_ANY, 0);
 	if (r == NULL)
-		r = rte_ring_create("test", RING_SIZE, SOCKET_ID_ANY, 0);
-	if (r == NULL)
-		return -1;
+		goto test_fail;
 
 	/* retrieve the ring from its name */
 	if (rte_ring_lookup("test") != r) {
 		printf("Cannot lookup ring from its name\n");
-		return -1;
+		goto test_fail;
 	}
 
 	/* burst operations */
-	if (test_ring_burst_basic() < 0)
-		return -1;
+	if (test_ring_burst_basic(r) < 0)
+		goto test_fail;
 
 	/* basic operations */
-	if (test_ring_basic() < 0)
-		return -1;
+	if (test_ring_basic(r) < 0)
+		goto test_fail;
 
 	/* basic operations */
 	if ( test_create_count_odd() < 0){
-			printf ("Test failed to detect odd count\n");
-			return -1;
-		}
-		else
-			printf ( "Test detected odd count\n");
+		printf("Test failed to detect odd count\n");
+		goto test_fail;
+	} else
+		printf("Test detected odd count\n");
 
 	if ( test_lookup_null() < 0){
-				printf ("Test failed to detect NULL ring lookup\n");
-				return -1;
-			}
-			else
-				printf ( "Test detected NULL ring lookup \n");
+		printf("Test failed to detect NULL ring lookup\n");
+		goto test_fail;
+	} else
+		printf("Test detected NULL ring lookup\n");
 
 	/* test of creating ring with wrong size */
 	if (test_ring_creation_with_wrong_size() < 0)
-		return -1;
+		goto test_fail;
 
 	/* test of creation ring with an used name */
 	if (test_ring_creation_with_an_used_name() < 0)
-		return -1;
+		goto test_fail;
 
 	if (test_ring_with_exact_size() < 0)
-		return -1;
+		goto test_fail;
 
 	/* dump the ring status */
 	rte_ring_list_dump(stdout);
 
+	rte_ring_free(r);
+
 	return 0;
+
+test_fail:
+	rte_ring_free(r);
+
+	return -1;
 }
 
 REGISTER_TEST_COMMAND(ring_autotest, test_ring);
-- 
2.7.4

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [dpdk-dev] [PATCH v2 4/6] test: fix memory leak in ring perf autotest
  2017-12-22 10:12 [dpdk-dev] [PATCH 1/6] test: fix memory leak in bitmap test Anatoly Burakov
                   ` (8 preceding siblings ...)
  2018-01-17  8:36 ` [dpdk-dev] [PATCH v2 3/6] test: fix memory leak in ring autotest Anatoly Burakov
@ 2018-01-17  8:36 ` Anatoly Burakov
  2018-01-17  8:36 ` [dpdk-dev] [PATCH v2 5/6] test: fix memory leak in table autotest Anatoly Burakov
                   ` (7 subsequent siblings)
  17 siblings, 0 replies; 47+ messages in thread
From: Anatoly Burakov @ 2018-01-17  8:36 UTC (permalink / raw)
  To: dev; +Cc: Olivier Matz, stable

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

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 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

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [dpdk-dev] [PATCH v2 5/6] test: fix memory leak in table autotest
  2017-12-22 10:12 [dpdk-dev] [PATCH 1/6] test: fix memory leak in bitmap test Anatoly Burakov
                   ` (9 preceding siblings ...)
  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 ` Anatoly Burakov
  2018-01-17  8:36 ` [dpdk-dev] [PATCH v2 6/6] test: fix memory leak in timer perf autotest Anatoly Burakov
                   ` (6 subsequent siblings)
  17 siblings, 0 replies; 47+ messages in thread
From: Anatoly Burakov @ 2018-01-17  8:36 UTC (permalink / raw)
  To: dev; +Cc: Cristian Dumitrescu, stable

Always deallocate allocated resources after the test is done.

Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>

Fixes: 5205954791cb ("app/test: packet framework unit tests")
Cc: cristian.dumitrescu@intel.com
Cc: stable@dpdk.org

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 test/test/test_table.c | 44 ++++++++++++++++++++++++++++----------------
 1 file changed, 28 insertions(+), 16 deletions(-)

diff --git a/test/test/test_table.c b/test/test/test_table.c
index c9268a3..f01652d 100644
--- a/test/test/test_table.c
+++ b/test/test/test_table.c
@@ -55,6 +55,14 @@ uint64_t pipeline_test_hash(void *key,
 }
 
 static void
+app_free_resources(void) {
+	int i;
+	for (i = 0; i < N_PORTS; i++)
+		rte_ring_free(rings_rx[i]);
+	rte_mempool_free(pool);
+}
+
+static void
 app_init_mbuf_pools(void)
 {
 	/* Init the buffer pool */
@@ -113,18 +121,20 @@ app_init_rings(void)
 static int
 test_table(void)
 {
-	int status, failures;
+	int status, ret;
 	unsigned i;
 
-	failures = 0;
+	ret = TEST_SUCCESS;
 
 	app_init_rings();
 	app_init_mbuf_pools();
 
 	printf("\n\n\n\n************Pipeline tests************\n");
 
-	if (test_table_pipeline() < 0)
-		return -1;
+	if (test_table_pipeline() < 0) {
+		ret = TEST_FAILED;
+		goto end;
+	}
 
 	printf("\n\n\n\n************Port tests************\n");
 	for (i = 0; i < n_port_tests; i++) {
@@ -132,8 +142,8 @@ test_table(void)
 		if (status < 0) {
 			printf("\nPort test number %d failed (%d).\n", i,
 				status);
-			failures++;
-			return -1;
+			ret = TEST_FAILED;
+			goto end;
 		}
 	}
 
@@ -143,8 +153,8 @@ test_table(void)
 		if (status < 0) {
 			printf("\nTable test number %d failed (%d).\n", i,
 				status);
-			failures++;
-			return -1;
+			ret = TEST_FAILED;
+			goto end;
 		}
 	}
 
@@ -154,21 +164,23 @@ test_table(void)
 		if (status < 0) {
 			printf("\nCombined table test number %d failed with "
 				"reason number %d.\n", i, status);
-			failures++;
-			return -1;
+			ret = TEST_FAILED;
+			goto end;
 		}
 	}
 
-	if (failures)
-		return -1;
-
 #ifdef RTE_LIBRTE_ACL
 	printf("\n\n\n\n************ACL tests************\n");
-	if (test_table_acl() < 0)
-		return -1;
+	if (test_table_acl() < 0) {
+		ret = TEST_FAILED;
+		goto end;
+	}
 #endif
 
-	return 0;
+end:
+	app_free_resources();
+
+	return ret;
 }
 
 REGISTER_TEST_COMMAND(table_autotest, test_table);
-- 
2.7.4

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [dpdk-dev] [PATCH v2 6/6] test: fix memory leak in timer perf autotest
  2017-12-22 10:12 [dpdk-dev] [PATCH 1/6] test: fix memory leak in bitmap test Anatoly Burakov
                   ` (10 preceding siblings ...)
  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 ` Anatoly Burakov
  2018-01-17 11:15 ` [dpdk-dev] [PATCH v3 1/6] test: fix memory leak in bitmap test Anatoly Burakov
                   ` (5 subsequent siblings)
  17 siblings, 0 replies; 47+ messages in thread
From: Anatoly Burakov @ 2018-01-17  8:36 UTC (permalink / raw)
  To: dev; +Cc: Robert Sanford, stable

Fixes: 277afaf3dbcb ("app/test: add timer_perf")
Cc: stable@dpdk.org

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 test/test/test_timer_perf.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/test/test/test_timer_perf.c b/test/test/test_timer_perf.c
index afa3a06..0fe2b74 100644
--- a/test/test/test_timer_perf.c
+++ b/test/test/test_timer_perf.c
@@ -127,6 +127,7 @@ test_timer_perf(void)
 	printf("Time per rte_timer_manage with zero callbacks: %"PRIu64" cycles\n",
 			(end_tsc - start_tsc + iterations/2) / iterations);
 
+	rte_free(tms);
 	return 0;
 }
 
-- 
2.7.4

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [dpdk-dev] [PATCH v2 3/6] test: fix memory leak in ring autotest
  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
  0 siblings, 0 replies; 47+ messages in thread
From: Burakov, Anatoly @ 2018-01-17  8:42 UTC (permalink / raw)
  To: dev

On 17-Jan-18 8:36 AM, Anatoly Burakov wrote:
> Get rid of global static ring variable and don't reuse rings
> between test runs.
> 
> Fixes: af75078fece3 ("first public release")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
> ---
>   test/test/test_ring.c | 61 ++++++++++++++++++++++++++++-----------------------
>   1 file changed, 33 insertions(+), 28 deletions(-)
> 
> diff --git a/test/test/test_ring.c b/test/test/test_ring.c
> index 19d497a..b339f04 100644
> --- a/test/test/test_ring.c
> +++ b/test/test/test_ring.c
> @@ -57,8 +57,6 @@
>   
>   static rte_atomic32_t synchro;
>   
> -static struct rte_ring *r;
> -
>   #define	TEST_RING_VERIFY(exp)						\
>   	if (!(exp)) {							\
>   		printf("error at %s:%d\tcondition " #exp " failed\n",	\
> @@ -73,7 +71,7 @@ static struct rte_ring *r;
>    * helper routine for test_ring_basic
>    */
>   static int
> -test_ring_basic_full_empty(void * const src[], void *dst[])
> +test_ring_basic_full_empty(struct rte_ring *r, void * const src[], void *dst[])
>   {
>   	unsigned i, rand;
>   	const unsigned rsz = RING_SIZE - 1;
> @@ -114,7 +112,7 @@ test_ring_basic_full_empty(void * const src[], void *dst[])
>   }
>   
>   static int
> -test_ring_basic(void)
> +test_ring_basic(struct rte_ring *r)
>   {
>   	void **src = NULL, **cur_src = NULL, **dst = NULL, **cur_dst = NULL;
>   	int ret;
> @@ -250,7 +248,7 @@ test_ring_basic(void)
>   		goto fail;
>   	}
>   
> -	if (test_ring_basic_full_empty(src, dst) != 0)
> +	if (test_ring_basic_full_empty(r, src, dst) != 0)
>   		goto fail;
>   
>   	cur_src = src;
> @@ -317,7 +315,7 @@ test_ring_basic(void)
>   }
>   
>   static int
> -test_ring_burst_basic(void)
> +test_ring_burst_basic(struct rte_ring *r)
>   {
>   	void **src = NULL, **cur_src = NULL, **dst = NULL, **cur_dst = NULL;
>   	int ret;
> @@ -731,6 +729,7 @@ test_ring_basic_ex(void)
>   
>   	ret = 0;
>   fail_test:
> +	rte_ring_free(rp);
>   	if (obj != NULL)
>   		rte_free(obj);
>   
> @@ -811,61 +810,67 @@ test_ring_with_exact_size(void)
>   static int
>   test_ring(void)
>   {
> +	struct rte_ring *r = NULL;
> +
>   	/* some more basic operations */
>   	if (test_ring_basic_ex() < 0)
> -		return -1;
> +		goto test_fail;
>   
>   	rte_atomic32_init(&synchro);
>   
> +	r = rte_ring_create("test", RING_SIZE, SOCKET_ID_ANY, 0);
>   	if (r == NULL)
> -		r = rte_ring_create("test", RING_SIZE, SOCKET_ID_ANY, 0);
> -	if (r == NULL)
> -		return -1;
> +		goto test_fail;
>   
>   	/* retrieve the ring from its name */
>   	if (rte_ring_lookup("test") != r) {
>   		printf("Cannot lookup ring from its name\n");
> -		return -1;
> +		goto test_fail;
>   	}
>   
>   	/* burst operations */
> -	if (test_ring_burst_basic() < 0)
> -		return -1;
> +	if (test_ring_burst_basic(r) < 0)
> +		goto test_fail;
>   
>   	/* basic operations */
> -	if (test_ring_basic() < 0)
> -		return -1;
> +	if (test_ring_basic(r) < 0)
> +		goto test_fail;
>   
>   	/* basic operations */
>   	if ( test_create_count_odd() < 0){
> -			printf ("Test failed to detect odd count\n");
> -			return -1;
> -		}
> -		else
> -			printf ( "Test detected odd count\n");
> +		printf("Test failed to detect odd count\n");
> +		goto test_fail;
> +	} else
> +		printf("Test detected odd count\n");
>   
>   	if ( test_lookup_null() < 0){
> -				printf ("Test failed to detect NULL ring lookup\n");
> -				return -1;
> -			}
> -			else
> -				printf ( "Test detected NULL ring lookup \n");
> +		printf("Test failed to detect NULL ring lookup\n");
> +		goto test_fail;
> +	} else
> +		printf("Test detected NULL ring lookup\n");
>   
>   	/* test of creating ring with wrong size */
>   	if (test_ring_creation_with_wrong_size() < 0)
> -		return -1;
> +		goto test_fail;
>   
>   	/* test of creation ring with an used name */
>   	if (test_ring_creation_with_an_used_name() < 0)
> -		return -1;
> +		goto test_fail;
>   
>   	if (test_ring_with_exact_size() < 0)
> -		return -1;
> +		goto test_fail;
>   
>   	/* dump the ring status */
>   	rte_ring_list_dump(stdout);
>   
> +	rte_ring_free(r);
> +
>   	return 0;
> +
> +test_fail:
> +	rte_ring_free(r);
> +
> +	return -1;
>   }
>   
>   REGISTER_TEST_COMMAND(ring_autotest, test_ring);
> 

Apologies, for some reason the old and incorrect commit message was 
attached. I'll respin it.

-- 
Thanks,
Anatoly

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [dpdk-dev] [PATCH v3 1/6] test: fix memory leak in bitmap test
  2017-12-22 10:12 [dpdk-dev] [PATCH 1/6] test: fix memory leak in bitmap test Anatoly Burakov
                   ` (11 preceding siblings ...)
  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 ` Anatoly Burakov
  2018-02-01  0:10   ` Thomas Monjalon
                     ` (6 more replies)
  2018-01-17 11:15 ` [dpdk-dev] [PATCH v3 2/6] test: fix memory leak in reorder autotest Anatoly Burakov
                   ` (4 subsequent siblings)
  17 siblings, 7 replies; 47+ messages in thread
From: Anatoly Burakov @ 2018-01-17 11:15 UTC (permalink / raw)
  To: dev; +Cc: Cristian Dumitrescu, pbhagavatula

Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>

Fixes: c7e4a134e769 ("test: verify bitmap operations")
Cc: pbhagavatula@caviumnetworks.com

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 test/test/test_bitmap.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/test/test/test_bitmap.c b/test/test/test_bitmap.c
index 05d547e..c3169e9 100644
--- a/test/test/test_bitmap.c
+++ b/test/test/test_bitmap.c
@@ -158,6 +158,9 @@ test_bitmap(void)
 	if (test_bitmap_scan_operations(bmp) < 0)
 		return TEST_FAILED;
 
+	rte_bitmap_free(bmp);
+	rte_free(mem);
+
 	return TEST_SUCCESS;
 }
 
-- 
2.7.4

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [dpdk-dev] [PATCH v3 2/6] test: fix memory leak in reorder autotest
  2017-12-22 10:12 [dpdk-dev] [PATCH 1/6] test: fix memory leak in bitmap test Anatoly Burakov
                   ` (12 preceding siblings ...)
  2018-01-17 11:15 ` [dpdk-dev] [PATCH v3 1/6] test: fix memory leak in bitmap test Anatoly Burakov
@ 2018-01-17 11:15 ` Anatoly Burakov
  2018-01-17 11:15 ` [dpdk-dev] [PATCH v3 3/6] test: fix memory leak in ring autotest Anatoly Burakov
                   ` (3 subsequent siblings)
  17 siblings, 0 replies; 47+ messages in thread
From: Anatoly Burakov @ 2018-01-17 11:15 UTC (permalink / raw)
  To: dev; +Cc: Reshma Pattan, sergio.gonzalez.monroy, reshma.pattan, stable

Add a teardown function that frees allocated resources.

Fixes: d0c9b58d7156 ("app/test: new reorder unit test")
Cc: sergio.gonzalez.monroy@intel.com
Cc: reshma.pattan@intek.com
Cc: stable@dpdk.org

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 test/test/test_reorder.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/test/test/test_reorder.c b/test/test/test_reorder.c
index e834bac..65e4f38 100644
--- a/test/test/test_reorder.c
+++ b/test/test/test_reorder.c
@@ -331,9 +331,20 @@ test_setup(void)
 	return 0;
 }
 
+static void
+test_teardown(void)
+{
+	rte_reorder_free(test_params->b);
+	test_params->b = NULL;
+	rte_mempool_free(test_params->p);
+	test_params->p = NULL;
+}
+
+
 static struct unit_test_suite reorder_test_suite  = {
 
 	.setup = test_setup,
+	.teardown = test_teardown,
 	.suite_name = "Reorder Unit Test Suite",
 	.unit_test_cases = {
 		TEST_CASE(test_reorder_create),
-- 
2.7.4

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [dpdk-dev] [PATCH v3 3/6] test: fix memory leak in ring autotest
  2017-12-22 10:12 [dpdk-dev] [PATCH 1/6] test: fix memory leak in bitmap test Anatoly Burakov
                   ` (13 preceding siblings ...)
  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 ` 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
                   ` (2 subsequent siblings)
  17 siblings, 1 reply; 47+ messages in thread
From: Anatoly Burakov @ 2018-01-17 11:15 UTC (permalink / raw)
  To: dev; +Cc: Olivier Matz, pablo.de.lara.guarch, stable

Get rid of global static ring variable and don't reuse rings
between test runs.

Fixes: 4e32101f9b01 ("ring: support freeing")
Cc: pablo.de.lara.guarch@intel.com
Cc: stable@dpdk.org

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---

Notes:
    v3: fix commit message to point to approriate commit being fixed
    v2: remove static ring variable

 test/test/test_ring.c | 61 ++++++++++++++++++++++++++++-----------------------
 1 file changed, 33 insertions(+), 28 deletions(-)

diff --git a/test/test/test_ring.c b/test/test/test_ring.c
index 19d497a..b339f04 100644
--- a/test/test/test_ring.c
+++ b/test/test/test_ring.c
@@ -57,8 +57,6 @@
 
 static rte_atomic32_t synchro;
 
-static struct rte_ring *r;
-
 #define	TEST_RING_VERIFY(exp)						\
 	if (!(exp)) {							\
 		printf("error at %s:%d\tcondition " #exp " failed\n",	\
@@ -73,7 +71,7 @@ static struct rte_ring *r;
  * helper routine for test_ring_basic
  */
 static int
-test_ring_basic_full_empty(void * const src[], void *dst[])
+test_ring_basic_full_empty(struct rte_ring *r, void * const src[], void *dst[])
 {
 	unsigned i, rand;
 	const unsigned rsz = RING_SIZE - 1;
@@ -114,7 +112,7 @@ test_ring_basic_full_empty(void * const src[], void *dst[])
 }
 
 static int
-test_ring_basic(void)
+test_ring_basic(struct rte_ring *r)
 {
 	void **src = NULL, **cur_src = NULL, **dst = NULL, **cur_dst = NULL;
 	int ret;
@@ -250,7 +248,7 @@ test_ring_basic(void)
 		goto fail;
 	}
 
-	if (test_ring_basic_full_empty(src, dst) != 0)
+	if (test_ring_basic_full_empty(r, src, dst) != 0)
 		goto fail;
 
 	cur_src = src;
@@ -317,7 +315,7 @@ test_ring_basic(void)
 }
 
 static int
-test_ring_burst_basic(void)
+test_ring_burst_basic(struct rte_ring *r)
 {
 	void **src = NULL, **cur_src = NULL, **dst = NULL, **cur_dst = NULL;
 	int ret;
@@ -731,6 +729,7 @@ test_ring_basic_ex(void)
 
 	ret = 0;
 fail_test:
+	rte_ring_free(rp);
 	if (obj != NULL)
 		rte_free(obj);
 
@@ -811,61 +810,67 @@ test_ring_with_exact_size(void)
 static int
 test_ring(void)
 {
+	struct rte_ring *r = NULL;
+
 	/* some more basic operations */
 	if (test_ring_basic_ex() < 0)
-		return -1;
+		goto test_fail;
 
 	rte_atomic32_init(&synchro);
 
+	r = rte_ring_create("test", RING_SIZE, SOCKET_ID_ANY, 0);
 	if (r == NULL)
-		r = rte_ring_create("test", RING_SIZE, SOCKET_ID_ANY, 0);
-	if (r == NULL)
-		return -1;
+		goto test_fail;
 
 	/* retrieve the ring from its name */
 	if (rte_ring_lookup("test") != r) {
 		printf("Cannot lookup ring from its name\n");
-		return -1;
+		goto test_fail;
 	}
 
 	/* burst operations */
-	if (test_ring_burst_basic() < 0)
-		return -1;
+	if (test_ring_burst_basic(r) < 0)
+		goto test_fail;
 
 	/* basic operations */
-	if (test_ring_basic() < 0)
-		return -1;
+	if (test_ring_basic(r) < 0)
+		goto test_fail;
 
 	/* basic operations */
 	if ( test_create_count_odd() < 0){
-			printf ("Test failed to detect odd count\n");
-			return -1;
-		}
-		else
-			printf ( "Test detected odd count\n");
+		printf("Test failed to detect odd count\n");
+		goto test_fail;
+	} else
+		printf("Test detected odd count\n");
 
 	if ( test_lookup_null() < 0){
-				printf ("Test failed to detect NULL ring lookup\n");
-				return -1;
-			}
-			else
-				printf ( "Test detected NULL ring lookup \n");
+		printf("Test failed to detect NULL ring lookup\n");
+		goto test_fail;
+	} else
+		printf("Test detected NULL ring lookup\n");
 
 	/* test of creating ring with wrong size */
 	if (test_ring_creation_with_wrong_size() < 0)
-		return -1;
+		goto test_fail;
 
 	/* test of creation ring with an used name */
 	if (test_ring_creation_with_an_used_name() < 0)
-		return -1;
+		goto test_fail;
 
 	if (test_ring_with_exact_size() < 0)
-		return -1;
+		goto test_fail;
 
 	/* dump the ring status */
 	rte_ring_list_dump(stdout);
 
+	rte_ring_free(r);
+
 	return 0;
+
+test_fail:
+	rte_ring_free(r);
+
+	return -1;
 }
 
 REGISTER_TEST_COMMAND(ring_autotest, test_ring);
-- 
2.7.4

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [dpdk-dev] [PATCH v3 4/6] test: fix memory leak in ring perf autotest
  2017-12-22 10:12 [dpdk-dev] [PATCH 1/6] test: fix memory leak in bitmap test Anatoly Burakov
                   ` (14 preceding siblings ...)
  2018-01-17 11:15 ` [dpdk-dev] [PATCH v3 3/6] test: fix memory leak in ring autotest Anatoly Burakov
@ 2018-01-17 11:15 ` 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
  17 siblings, 1 reply; 47+ messages in thread
From: Anatoly Burakov @ 2018-01-17 11:15 UTC (permalink / raw)
  To: dev; +Cc: Olivier Matz, stable

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

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.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

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [dpdk-dev] [PATCH v3 5/6] test: fix memory leak in table autotest
  2017-12-22 10:12 [dpdk-dev] [PATCH 1/6] test: fix memory leak in bitmap test Anatoly Burakov
                   ` (15 preceding siblings ...)
  2018-01-17 11:15 ` [dpdk-dev] [PATCH v3 4/6] test: fix memory leak in ring perf autotest Anatoly Burakov
@ 2018-01-17 11:15 ` Anatoly Burakov
  2018-01-17 11:15 ` [dpdk-dev] [PATCH v3 6/6] test: fix memory leak in timer perf autotest Anatoly Burakov
  17 siblings, 0 replies; 47+ messages in thread
From: Anatoly Burakov @ 2018-01-17 11:15 UTC (permalink / raw)
  To: dev; +Cc: Cristian Dumitrescu, stable

Always deallocate allocated resources after the test is done.

Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>

Fixes: 5205954791cb ("app/test: packet framework unit tests")
Cc: cristian.dumitrescu@intel.com
Cc: stable@dpdk.org

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 test/test/test_table.c | 44 ++++++++++++++++++++++++++++----------------
 1 file changed, 28 insertions(+), 16 deletions(-)

diff --git a/test/test/test_table.c b/test/test/test_table.c
index c9268a3..f01652d 100644
--- a/test/test/test_table.c
+++ b/test/test/test_table.c
@@ -55,6 +55,14 @@ uint64_t pipeline_test_hash(void *key,
 }
 
 static void
+app_free_resources(void) {
+	int i;
+	for (i = 0; i < N_PORTS; i++)
+		rte_ring_free(rings_rx[i]);
+	rte_mempool_free(pool);
+}
+
+static void
 app_init_mbuf_pools(void)
 {
 	/* Init the buffer pool */
@@ -113,18 +121,20 @@ app_init_rings(void)
 static int
 test_table(void)
 {
-	int status, failures;
+	int status, ret;
 	unsigned i;
 
-	failures = 0;
+	ret = TEST_SUCCESS;
 
 	app_init_rings();
 	app_init_mbuf_pools();
 
 	printf("\n\n\n\n************Pipeline tests************\n");
 
-	if (test_table_pipeline() < 0)
-		return -1;
+	if (test_table_pipeline() < 0) {
+		ret = TEST_FAILED;
+		goto end;
+	}
 
 	printf("\n\n\n\n************Port tests************\n");
 	for (i = 0; i < n_port_tests; i++) {
@@ -132,8 +142,8 @@ test_table(void)
 		if (status < 0) {
 			printf("\nPort test number %d failed (%d).\n", i,
 				status);
-			failures++;
-			return -1;
+			ret = TEST_FAILED;
+			goto end;
 		}
 	}
 
@@ -143,8 +153,8 @@ test_table(void)
 		if (status < 0) {
 			printf("\nTable test number %d failed (%d).\n", i,
 				status);
-			failures++;
-			return -1;
+			ret = TEST_FAILED;
+			goto end;
 		}
 	}
 
@@ -154,21 +164,23 @@ test_table(void)
 		if (status < 0) {
 			printf("\nCombined table test number %d failed with "
 				"reason number %d.\n", i, status);
-			failures++;
-			return -1;
+			ret = TEST_FAILED;
+			goto end;
 		}
 	}
 
-	if (failures)
-		return -1;
-
 #ifdef RTE_LIBRTE_ACL
 	printf("\n\n\n\n************ACL tests************\n");
-	if (test_table_acl() < 0)
-		return -1;
+	if (test_table_acl() < 0) {
+		ret = TEST_FAILED;
+		goto end;
+	}
 #endif
 
-	return 0;
+end:
+	app_free_resources();
+
+	return ret;
 }
 
 REGISTER_TEST_COMMAND(table_autotest, test_table);
-- 
2.7.4

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [dpdk-dev] [PATCH v3 6/6] test: fix memory leak in timer perf autotest
  2017-12-22 10:12 [dpdk-dev] [PATCH 1/6] test: fix memory leak in bitmap test Anatoly Burakov
                   ` (16 preceding siblings ...)
  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 ` Anatoly Burakov
  17 siblings, 0 replies; 47+ messages in thread
From: Anatoly Burakov @ 2018-01-17 11:15 UTC (permalink / raw)
  To: dev; +Cc: Robert Sanford, stable

Fixes: 277afaf3dbcb ("app/test: add timer_perf")
Cc: stable@dpdk.org

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 test/test/test_timer_perf.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/test/test/test_timer_perf.c b/test/test/test_timer_perf.c
index afa3a06..0fe2b74 100644
--- a/test/test/test_timer_perf.c
+++ b/test/test/test_timer_perf.c
@@ -127,6 +127,7 @@ test_timer_perf(void)
 	printf("Time per rte_timer_manage with zero callbacks: %"PRIu64" cycles\n",
 			(end_tsc - start_tsc + iterations/2) / iterations);
 
+	rte_free(tms);
 	return 0;
 }
 
-- 
2.7.4

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [dpdk-dev] [PATCH v3 3/6] test: fix memory leak in ring autotest
  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
  0 siblings, 0 replies; 47+ messages in thread
From: Olivier Matz @ 2018-01-19  8:33 UTC (permalink / raw)
  To: Anatoly Burakov; +Cc: dev, pablo.de.lara.guarch, stable

On Wed, Jan 17, 2018 at 11:15:53AM +0000, Anatoly Burakov wrote:
> Get rid of global static ring variable and don't reuse rings
> between test runs.
> 
> Fixes: 4e32101f9b01 ("ring: support freeing")
> Cc: pablo.de.lara.guarch@intel.com
> Cc: stable@dpdk.org
> 
> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>

Acked-by: Olivier Matz <olivier.matz@6wind.com>

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [dpdk-dev] [PATCH v3 4/6] test: fix memory leak in ring perf autotest
  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
  0 siblings, 0 replies; 47+ messages in thread
From: Olivier Matz @ 2018-01-19  8:35 UTC (permalink / raw)
  To: Anatoly Burakov; +Cc: dev, stable

On Wed, Jan 17, 2018 at 11:15:54AM +0000, Anatoly Burakov wrote:
> 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>

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [dpdk-dev] [PATCH v3 1/6] test: fix memory leak in bitmap test
  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-05 13:03   ` [dpdk-dev] [PATCH v4 " Anatoly Burakov
                     ` (5 subsequent siblings)
  6 siblings, 1 reply; 47+ messages in thread
From: Thomas Monjalon @ 2018-02-01  0:10 UTC (permalink / raw)
  To: Anatoly Burakov; +Cc: dev, Cristian Dumitrescu, pbhagavatula

17/01/2018 12:15, Anatoly Burakov:
> Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
> 
> Fixes: c7e4a134e769 ("test: verify bitmap operations")
> Cc: pbhagavatula@caviumnetworks.com
> 
> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>

I think you missed to report some previous acks in this series.

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [dpdk-dev] [PATCH v3 1/6] test: fix memory leak in bitmap test
  2018-02-01  0:10   ` Thomas Monjalon
@ 2018-02-01 17:04     ` Burakov, Anatoly
  2018-02-02  9:08       ` Thomas Monjalon
  0 siblings, 1 reply; 47+ messages in thread
From: Burakov, Anatoly @ 2018-02-01 17:04 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev, Cristian Dumitrescu, pbhagavatula

On 01-Feb-18 12:10 AM, Thomas Monjalon wrote:
> 17/01/2018 12:15, Anatoly Burakov:
>> Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
>>
>> Fixes: c7e4a134e769 ("test: verify bitmap operations")
>> Cc: pbhagavatula@caviumnetworks.com
>>
>> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
> 
> I think you missed to report some previous acks in this series.
> 
> 
> 

Which ones were there? I can only see two new acks for v3 from Olivier. 
Everything else seems in order, unless my email client is lying to me :)

-- 
Thanks,
Anatoly

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [dpdk-dev] [PATCH v3 1/6] test: fix memory leak in bitmap test
  2018-02-01 17:04     ` Burakov, Anatoly
@ 2018-02-02  9:08       ` Thomas Monjalon
  2018-02-02 10:31         ` Burakov, Anatoly
  0 siblings, 1 reply; 47+ messages in thread
From: Thomas Monjalon @ 2018-02-02  9:08 UTC (permalink / raw)
  To: Burakov, Anatoly; +Cc: dev, Cristian Dumitrescu, pbhagavatula

01/02/2018 18:04, Burakov, Anatoly:
> On 01-Feb-18 12:10 AM, Thomas Monjalon wrote:
> > 17/01/2018 12:15, Anatoly Burakov:
> >> Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
> >>
> >> Fixes: c7e4a134e769 ("test: verify bitmap operations")
> >> Cc: pbhagavatula@caviumnetworks.com
> >>
> >> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
> > 
> > I think you missed to report some previous acks in this series.
> > 
> > 
> > 
> 
> Which ones were there? I can only see two new acks for v3 from Olivier. 
> Everything else seems in order, unless my email client is lying to me :)

There are some acks from Cristian.

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [dpdk-dev] [PATCH v3 1/6] test: fix memory leak in bitmap test
  2018-02-02  9:08       ` Thomas Monjalon
@ 2018-02-02 10:31         ` Burakov, Anatoly
  2018-02-02 17:08           ` Thomas Monjalon
  0 siblings, 1 reply; 47+ messages in thread
From: Burakov, Anatoly @ 2018-02-02 10:31 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev, Cristian Dumitrescu, pbhagavatula

On 02-Feb-18 9:08 AM, Thomas Monjalon wrote:
> 01/02/2018 18:04, Burakov, Anatoly:
>> On 01-Feb-18 12:10 AM, Thomas Monjalon wrote:
>>> 17/01/2018 12:15, Anatoly Burakov:
>>>> Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
>>>>
>>>> Fixes: c7e4a134e769 ("test: verify bitmap operations")
>>>> Cc: pbhagavatula@caviumnetworks.com
>>>>
>>>> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
>>>
>>> I think you missed to report some previous acks in this series.
>>>
>>>
>>>
>>
>> Which ones were there? I can only see two new acks for v3 from Olivier.
>> Everything else seems in order, unless my email client is lying to me :)
> 
> There are some acks from Cristian.
> 
They are all already in the patchset.

-- 
Thanks,
Anatoly

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [dpdk-dev] [PATCH v3 1/6] test: fix memory leak in bitmap test
  2018-02-02 10:31         ` Burakov, Anatoly
@ 2018-02-02 17:08           ` Thomas Monjalon
  2018-02-05 10:06             ` Burakov, Anatoly
  0 siblings, 1 reply; 47+ messages in thread
From: Thomas Monjalon @ 2018-02-02 17:08 UTC (permalink / raw)
  To: Burakov, Anatoly; +Cc: dev, Cristian Dumitrescu, pbhagavatula

02/02/2018 11:31, Burakov, Anatoly:
> On 02-Feb-18 9:08 AM, Thomas Monjalon wrote:
> > 01/02/2018 18:04, Burakov, Anatoly:
> >> On 01-Feb-18 12:10 AM, Thomas Monjalon wrote:
> >>> 17/01/2018 12:15, Anatoly Burakov:
> >>>> Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
> >>>>
> >>>> Fixes: c7e4a134e769 ("test: verify bitmap operations")
> >>>> Cc: pbhagavatula@caviumnetworks.com
> >>>>
> >>>> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
> >>>
> >>> I think you missed to report some previous acks in this series.
> >>>
> >>>
> >>>
> >>
> >> Which ones were there? I can only see two new acks for v3 from Olivier.
> >> Everything else seems in order, unless my email client is lying to me :)
> > 
> > There are some acks from Cristian.
> > 
> They are all already in the patchset.

Oh, I didn't see them because they are at the beginning or middle of
the message. They should be in chronological order after your Signed-off.

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [dpdk-dev] [PATCH v3 1/6] test: fix memory leak in bitmap test
  2018-02-02 17:08           ` Thomas Monjalon
@ 2018-02-05 10:06             ` Burakov, Anatoly
  2018-02-05 10:25               ` Thomas Monjalon
  0 siblings, 1 reply; 47+ messages in thread
From: Burakov, Anatoly @ 2018-02-05 10:06 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev, Cristian Dumitrescu, pbhagavatula

On 02-Feb-18 5:08 PM, Thomas Monjalon wrote:
> 02/02/2018 11:31, Burakov, Anatoly:
>> On 02-Feb-18 9:08 AM, Thomas Monjalon wrote:
>>> 01/02/2018 18:04, Burakov, Anatoly:
>>>> On 01-Feb-18 12:10 AM, Thomas Monjalon wrote:
>>>>> 17/01/2018 12:15, Anatoly Burakov:
>>>>>> Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
>>>>>>
>>>>>> Fixes: c7e4a134e769 ("test: verify bitmap operations")
>>>>>> Cc: pbhagavatula@caviumnetworks.com
>>>>>>
>>>>>> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
>>>>>
>>>>> I think you missed to report some previous acks in this series.
>>>>>
>>>>>
>>>>>
>>>>
>>>> Which ones were there? I can only see two new acks for v3 from Olivier.
>>>> Everything else seems in order, unless my email client is lying to me :)
>>>
>>> There are some acks from Cristian.
>>>
>> They are all already in the patchset.
> 
> Oh, I didn't see them because they are at the beginning or middle of
> the message. They should be in chronological order after your Signed-off.
> 
> 

That's a bit hard to do since my signoff is generated by 
git-format-patch rather than manually, but OK, i'll see what i can do. 
Apologies for the confusion.

-- 
Thanks,
Anatoly

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [dpdk-dev] [PATCH v3 1/6] test: fix memory leak in bitmap test
  2018-02-05 10:06             ` Burakov, Anatoly
@ 2018-02-05 10:25               ` Thomas Monjalon
  0 siblings, 0 replies; 47+ messages in thread
From: Thomas Monjalon @ 2018-02-05 10:25 UTC (permalink / raw)
  To: Burakov, Anatoly; +Cc: dev, Cristian Dumitrescu, pbhagavatula

05/02/2018 11:06, Burakov, Anatoly:
> On 02-Feb-18 5:08 PM, Thomas Monjalon wrote:
> > 02/02/2018 11:31, Burakov, Anatoly:
> >> On 02-Feb-18 9:08 AM, Thomas Monjalon wrote:
> >>> 01/02/2018 18:04, Burakov, Anatoly:
> >>>> On 01-Feb-18 12:10 AM, Thomas Monjalon wrote:
> >>>>> 17/01/2018 12:15, Anatoly Burakov:
> >>>>>> Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
> >>>>>>
> >>>>>> Fixes: c7e4a134e769 ("test: verify bitmap operations")
> >>>>>> Cc: pbhagavatula@caviumnetworks.com
> >>>>>>
> >>>>>> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
> >>>>>
> >>>>> I think you missed to report some previous acks in this series.
> >>>>>
> >>>>>
> >>>>>
> >>>>
> >>>> Which ones were there? I can only see two new acks for v3 from Olivier.
> >>>> Everything else seems in order, unless my email client is lying to me :)
> >>>
> >>> There are some acks from Cristian.
> >>>
> >> They are all already in the patchset.
> > 
> > Oh, I didn't see them because they are at the beginning or middle of
> > the message. They should be in chronological order after your Signed-off.
> > 
> > 
> 
> That's a bit hard to do since my signoff is generated by 
> git-format-patch rather than manually, but OK, i'll see what i can do. 
> Apologies for the confusion.

Your signed-off should be generated when creating the commit:
	git commit -s
Then you add acks by updating the commit:
	git commit --amend

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [dpdk-dev] [PATCH v4 1/6] test: fix memory leak in bitmap test
  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-05 13:03   ` Anatoly Burakov
  2018-02-06 13:35     ` [dpdk-dev] [PATCH v5 " Anatoly Burakov
                       ` (5 more replies)
  2018-02-05 13:03   ` [dpdk-dev] [PATCH v4 2/6] test: fix memory leak in reorder autotest Anatoly Burakov
                     ` (4 subsequent siblings)
  6 siblings, 6 replies; 47+ messages in thread
From: Anatoly Burakov @ 2018-02-05 13:03 UTC (permalink / raw)
  To: dev; +Cc: Cristian Dumitrescu, pbhagavatula

Fixes: c7e4a134e769 ("test: verify bitmap operations")
Cc: pbhagavatula@caviumnetworks.com

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
---

Notes:
    v4: put ack after signoff

 test/test/test_bitmap.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/test/test/test_bitmap.c b/test/test/test_bitmap.c
index 05d547e..c3169e9 100644
--- a/test/test/test_bitmap.c
+++ b/test/test/test_bitmap.c
@@ -158,6 +158,9 @@ test_bitmap(void)
 	if (test_bitmap_scan_operations(bmp) < 0)
 		return TEST_FAILED;
 
+	rte_bitmap_free(bmp);
+	rte_free(mem);
+
 	return TEST_SUCCESS;
 }
 
-- 
2.7.4

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [dpdk-dev] [PATCH v4 2/6] test: fix memory leak in reorder autotest
  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-05 13:03   ` [dpdk-dev] [PATCH v4 " Anatoly Burakov
@ 2018-02-05 13:03   ` Anatoly Burakov
  2018-02-05 13:03   ` [dpdk-dev] [PATCH v4 3/6] test: fix memory leak in ring autotest Anatoly Burakov
                     ` (3 subsequent siblings)
  6 siblings, 0 replies; 47+ messages in thread
From: Anatoly Burakov @ 2018-02-05 13:03 UTC (permalink / raw)
  To: dev; +Cc: Reshma Pattan, sergio.gonzalez.monroy, stable

Add a teardown function that frees allocated resources.

Fixes: d0c9b58d7156 ("app/test: new reorder unit test")
Cc: sergio.gonzalez.monroy@intel.com
Cc: reshma.pattan@intel.com
Cc: stable@dpdk.org

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---

Notes:
    v4: fix Reshma Pattan's email address

 test/test/test_reorder.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/test/test/test_reorder.c b/test/test/test_reorder.c
index e834bac..65e4f38 100644
--- a/test/test/test_reorder.c
+++ b/test/test/test_reorder.c
@@ -331,9 +331,20 @@ test_setup(void)
 	return 0;
 }
 
+static void
+test_teardown(void)
+{
+	rte_reorder_free(test_params->b);
+	test_params->b = NULL;
+	rte_mempool_free(test_params->p);
+	test_params->p = NULL;
+}
+
+
 static struct unit_test_suite reorder_test_suite  = {
 
 	.setup = test_setup,
+	.teardown = test_teardown,
 	.suite_name = "Reorder Unit Test Suite",
 	.unit_test_cases = {
 		TEST_CASE(test_reorder_create),
-- 
2.7.4

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [dpdk-dev] [PATCH v4 3/6] test: fix memory leak in ring autotest
  2018-01-17 11:15 ` [dpdk-dev] [PATCH v3 1/6] test: fix memory leak in bitmap test Anatoly Burakov
                     ` (2 preceding siblings ...)
  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   ` Anatoly Burakov
  2018-02-06  0:36     ` Thomas Monjalon
  2018-02-05 13:03   ` [dpdk-dev] [PATCH v4 4/6] test: fix memory leak in ring perf autotest Anatoly Burakov
                     ` (2 subsequent siblings)
  6 siblings, 1 reply; 47+ messages in thread
From: Anatoly Burakov @ 2018-02-05 13:03 UTC (permalink / raw)
  To: dev; +Cc: Olivier Matz, pablo.de.lara.guarch, stable

Get rid of global static ring variable and don't reuse rings
between test runs.

Fixes: 4e32101f9b01 ("ring: support freeing")
Cc: pablo.de.lara.guarch@intel.com
Cc: stable@dpdk.org

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

Notes:
    v3: fix commit message to point to approriate commit being fixed
    v2: remove static ring variable

 test/test/test_ring.c | 61 ++++++++++++++++++++++++++++-----------------------
 1 file changed, 33 insertions(+), 28 deletions(-)

diff --git a/test/test/test_ring.c b/test/test/test_ring.c
index 19d497a..b339f04 100644
--- a/test/test/test_ring.c
+++ b/test/test/test_ring.c
@@ -57,8 +57,6 @@
 
 static rte_atomic32_t synchro;
 
-static struct rte_ring *r;
-
 #define	TEST_RING_VERIFY(exp)						\
 	if (!(exp)) {							\
 		printf("error at %s:%d\tcondition " #exp " failed\n",	\
@@ -73,7 +71,7 @@ static struct rte_ring *r;
  * helper routine for test_ring_basic
  */
 static int
-test_ring_basic_full_empty(void * const src[], void *dst[])
+test_ring_basic_full_empty(struct rte_ring *r, void * const src[], void *dst[])
 {
 	unsigned i, rand;
 	const unsigned rsz = RING_SIZE - 1;
@@ -114,7 +112,7 @@ test_ring_basic_full_empty(void * const src[], void *dst[])
 }
 
 static int
-test_ring_basic(void)
+test_ring_basic(struct rte_ring *r)
 {
 	void **src = NULL, **cur_src = NULL, **dst = NULL, **cur_dst = NULL;
 	int ret;
@@ -250,7 +248,7 @@ test_ring_basic(void)
 		goto fail;
 	}
 
-	if (test_ring_basic_full_empty(src, dst) != 0)
+	if (test_ring_basic_full_empty(r, src, dst) != 0)
 		goto fail;
 
 	cur_src = src;
@@ -317,7 +315,7 @@ test_ring_basic(void)
 }
 
 static int
-test_ring_burst_basic(void)
+test_ring_burst_basic(struct rte_ring *r)
 {
 	void **src = NULL, **cur_src = NULL, **dst = NULL, **cur_dst = NULL;
 	int ret;
@@ -731,6 +729,7 @@ test_ring_basic_ex(void)
 
 	ret = 0;
 fail_test:
+	rte_ring_free(rp);
 	if (obj != NULL)
 		rte_free(obj);
 
@@ -811,61 +810,67 @@ test_ring_with_exact_size(void)
 static int
 test_ring(void)
 {
+	struct rte_ring *r = NULL;
+
 	/* some more basic operations */
 	if (test_ring_basic_ex() < 0)
-		return -1;
+		goto test_fail;
 
 	rte_atomic32_init(&synchro);
 
+	r = rte_ring_create("test", RING_SIZE, SOCKET_ID_ANY, 0);
 	if (r == NULL)
-		r = rte_ring_create("test", RING_SIZE, SOCKET_ID_ANY, 0);
-	if (r == NULL)
-		return -1;
+		goto test_fail;
 
 	/* retrieve the ring from its name */
 	if (rte_ring_lookup("test") != r) {
 		printf("Cannot lookup ring from its name\n");
-		return -1;
+		goto test_fail;
 	}
 
 	/* burst operations */
-	if (test_ring_burst_basic() < 0)
-		return -1;
+	if (test_ring_burst_basic(r) < 0)
+		goto test_fail;
 
 	/* basic operations */
-	if (test_ring_basic() < 0)
-		return -1;
+	if (test_ring_basic(r) < 0)
+		goto test_fail;
 
 	/* basic operations */
 	if ( test_create_count_odd() < 0){
-			printf ("Test failed to detect odd count\n");
-			return -1;
-		}
-		else
-			printf ( "Test detected odd count\n");
+		printf("Test failed to detect odd count\n");
+		goto test_fail;
+	} else
+		printf("Test detected odd count\n");
 
 	if ( test_lookup_null() < 0){
-				printf ("Test failed to detect NULL ring lookup\n");
-				return -1;
-			}
-			else
-				printf ( "Test detected NULL ring lookup \n");
+		printf("Test failed to detect NULL ring lookup\n");
+		goto test_fail;
+	} else
+		printf("Test detected NULL ring lookup\n");
 
 	/* test of creating ring with wrong size */
 	if (test_ring_creation_with_wrong_size() < 0)
-		return -1;
+		goto test_fail;
 
 	/* test of creation ring with an used name */
 	if (test_ring_creation_with_an_used_name() < 0)
-		return -1;
+		goto test_fail;
 
 	if (test_ring_with_exact_size() < 0)
-		return -1;
+		goto test_fail;
 
 	/* dump the ring status */
 	rte_ring_list_dump(stdout);
 
+	rte_ring_free(r);
+
 	return 0;
+
+test_fail:
+	rte_ring_free(r);
+
+	return -1;
 }
 
 REGISTER_TEST_COMMAND(ring_autotest, test_ring);
-- 
2.7.4

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [dpdk-dev] [PATCH v4 4/6] test: fix memory leak in ring perf autotest
  2018-01-17 11:15 ` [dpdk-dev] [PATCH v3 1/6] test: fix memory leak in bitmap test Anatoly Burakov
                     ` (3 preceding siblings ...)
  2018-02-05 13:03   ` [dpdk-dev] [PATCH v4 3/6] test: fix memory leak in ring autotest Anatoly Burakov
@ 2018-02-05 13:03   ` Anatoly Burakov
  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
  6 siblings, 0 replies; 47+ messages in thread
From: Anatoly Burakov @ 2018-02-05 13:03 UTC (permalink / raw)
  To: dev; +Cc: Olivier Matz, stable

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

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [dpdk-dev] [PATCH v4 5/6] test: fix memory leak in table autotest
  2018-01-17 11:15 ` [dpdk-dev] [PATCH v3 1/6] test: fix memory leak in bitmap test Anatoly Burakov
                     ` (4 preceding siblings ...)
  2018-02-05 13:03   ` [dpdk-dev] [PATCH v4 4/6] test: fix memory leak in ring perf autotest Anatoly Burakov
@ 2018-02-05 13:03   ` Anatoly Burakov
  2018-02-05 13:03   ` [dpdk-dev] [PATCH v4 6/6] test: fix memory leak in timer perf autotest Anatoly Burakov
  6 siblings, 0 replies; 47+ messages in thread
From: Anatoly Burakov @ 2018-02-05 13:03 UTC (permalink / raw)
  To: dev; +Cc: Cristian Dumitrescu, stable

Always deallocate allocated resources after the test is done.

Fixes: 5205954791cb ("app/test: packet framework unit tests")
Cc: cristian.dumitrescu@intel.com
Cc: stable@dpdk.org

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
---

Notes:
    v4: put ack after signoff

 test/test/test_table.c | 44 ++++++++++++++++++++++++++++----------------
 1 file changed, 28 insertions(+), 16 deletions(-)

diff --git a/test/test/test_table.c b/test/test/test_table.c
index c9268a3..f01652d 100644
--- a/test/test/test_table.c
+++ b/test/test/test_table.c
@@ -55,6 +55,14 @@ uint64_t pipeline_test_hash(void *key,
 }
 
 static void
+app_free_resources(void) {
+	int i;
+	for (i = 0; i < N_PORTS; i++)
+		rte_ring_free(rings_rx[i]);
+	rte_mempool_free(pool);
+}
+
+static void
 app_init_mbuf_pools(void)
 {
 	/* Init the buffer pool */
@@ -113,18 +121,20 @@ app_init_rings(void)
 static int
 test_table(void)
 {
-	int status, failures;
+	int status, ret;
 	unsigned i;
 
-	failures = 0;
+	ret = TEST_SUCCESS;
 
 	app_init_rings();
 	app_init_mbuf_pools();
 
 	printf("\n\n\n\n************Pipeline tests************\n");
 
-	if (test_table_pipeline() < 0)
-		return -1;
+	if (test_table_pipeline() < 0) {
+		ret = TEST_FAILED;
+		goto end;
+	}
 
 	printf("\n\n\n\n************Port tests************\n");
 	for (i = 0; i < n_port_tests; i++) {
@@ -132,8 +142,8 @@ test_table(void)
 		if (status < 0) {
 			printf("\nPort test number %d failed (%d).\n", i,
 				status);
-			failures++;
-			return -1;
+			ret = TEST_FAILED;
+			goto end;
 		}
 	}
 
@@ -143,8 +153,8 @@ test_table(void)
 		if (status < 0) {
 			printf("\nTable test number %d failed (%d).\n", i,
 				status);
-			failures++;
-			return -1;
+			ret = TEST_FAILED;
+			goto end;
 		}
 	}
 
@@ -154,21 +164,23 @@ test_table(void)
 		if (status < 0) {
 			printf("\nCombined table test number %d failed with "
 				"reason number %d.\n", i, status);
-			failures++;
-			return -1;
+			ret = TEST_FAILED;
+			goto end;
 		}
 	}
 
-	if (failures)
-		return -1;
-
 #ifdef RTE_LIBRTE_ACL
 	printf("\n\n\n\n************ACL tests************\n");
-	if (test_table_acl() < 0)
-		return -1;
+	if (test_table_acl() < 0) {
+		ret = TEST_FAILED;
+		goto end;
+	}
 #endif
 
-	return 0;
+end:
+	app_free_resources();
+
+	return ret;
 }
 
 REGISTER_TEST_COMMAND(table_autotest, test_table);
-- 
2.7.4

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [dpdk-dev] [PATCH v4 6/6] test: fix memory leak in timer perf autotest
  2018-01-17 11:15 ` [dpdk-dev] [PATCH v3 1/6] test: fix memory leak in bitmap test Anatoly Burakov
                     ` (5 preceding siblings ...)
  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   ` Anatoly Burakov
  6 siblings, 0 replies; 47+ messages in thread
From: Anatoly Burakov @ 2018-02-05 13:03 UTC (permalink / raw)
  To: dev; +Cc: Robert Sanford, stable

Fixes: 277afaf3dbcb ("app/test: add timer_perf")
Cc: stable@dpdk.org

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 test/test/test_timer_perf.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/test/test/test_timer_perf.c b/test/test/test_timer_perf.c
index afa3a06..0fe2b74 100644
--- a/test/test/test_timer_perf.c
+++ b/test/test/test_timer_perf.c
@@ -127,6 +127,7 @@ test_timer_perf(void)
 	printf("Time per rte_timer_manage with zero callbacks: %"PRIu64" cycles\n",
 			(end_tsc - start_tsc + iterations/2) / iterations);
 
+	rte_free(tms);
 	return 0;
 }
 
-- 
2.7.4

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [dpdk-dev] [PATCH v4 3/6] test: fix memory leak in ring autotest
  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
  0 siblings, 0 replies; 47+ messages in thread
From: Thomas Monjalon @ 2018-02-06  0:36 UTC (permalink / raw)
  To: Anatoly Burakov; +Cc: dev, Olivier Matz, pablo.de.lara.guarch, stable

05/02/2018 14:03, Anatoly Burakov:
> Get rid of global static ring variable and don't reuse rings
> between test runs.
> 
> Fixes: 4e32101f9b01 ("ring: support freeing")
> Cc: pablo.de.lara.guarch@intel.com
> Cc: stable@dpdk.org
> 
> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
> Acked-by: Olivier Matz <olivier.matz@6wind.com>

There is an error caught by clang:

test/test/test_ring.c:676:6: fatal error:
variable 'rp' is used uninitialized whenever 'if' condition is true
[-Wsometimes-uninitialized]

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [dpdk-dev] [PATCH v5 1/6] test: fix memory leak in bitmap test
  2018-02-05 13:03   ` [dpdk-dev] [PATCH v4 " Anatoly Burakov
@ 2018-02-06 13:35     ` 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
                       ` (4 subsequent siblings)
  5 siblings, 1 reply; 47+ messages in thread
From: Anatoly Burakov @ 2018-02-06 13:35 UTC (permalink / raw)
  To: dev; +Cc: Cristian Dumitrescu, pbhagavatula

Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>

Fixes: c7e4a134e769 ("test: verify bitmap operations")
Cc: pbhagavatula@caviumnetworks.com
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---

Notes:
    v4: put ack after signoff

 test/test/test_bitmap.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/test/test/test_bitmap.c b/test/test/test_bitmap.c
index 05d547e..c3169e9 100644
--- a/test/test/test_bitmap.c
+++ b/test/test/test_bitmap.c
@@ -158,6 +158,9 @@ test_bitmap(void)
 	if (test_bitmap_scan_operations(bmp) < 0)
 		return TEST_FAILED;
 
+	rte_bitmap_free(bmp);
+	rte_free(mem);
+
 	return TEST_SUCCESS;
 }
 
-- 
2.7.4

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [dpdk-dev] [PATCH v5 2/6] test: fix memory leak in reorder autotest
  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 13:35     ` Anatoly Burakov
  2018-02-06 13:35     ` [dpdk-dev] [PATCH v5 3/6] test: fix memory leak in ring autotest Anatoly Burakov
                       ` (3 subsequent siblings)
  5 siblings, 0 replies; 47+ messages in thread
From: Anatoly Burakov @ 2018-02-06 13:35 UTC (permalink / raw)
  To: dev; +Cc: Reshma Pattan, sergio.gonzalez.monroy, stable

Add a teardown function that frees allocated resources.

Fixes: d0c9b58d7156 ("app/test: new reorder unit test")
Cc: sergio.gonzalez.monroy@intel.com
Cc: reshma.pattan@intel.com
Cc: stable@dpdk.org
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---

Notes:
    v4: fix Reshma Pattan's email address

 test/test/test_reorder.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/test/test/test_reorder.c b/test/test/test_reorder.c
index e834bac..65e4f38 100644
--- a/test/test/test_reorder.c
+++ b/test/test/test_reorder.c
@@ -331,9 +331,20 @@ test_setup(void)
 	return 0;
 }
 
+static void
+test_teardown(void)
+{
+	rte_reorder_free(test_params->b);
+	test_params->b = NULL;
+	rte_mempool_free(test_params->p);
+	test_params->p = NULL;
+}
+
+
 static struct unit_test_suite reorder_test_suite  = {
 
 	.setup = test_setup,
+	.teardown = test_teardown,
 	.suite_name = "Reorder Unit Test Suite",
 	.unit_test_cases = {
 		TEST_CASE(test_reorder_create),
-- 
2.7.4

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [dpdk-dev] [PATCH v5 3/6] test: fix memory leak in ring autotest
  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 13:35     ` [dpdk-dev] [PATCH v5 2/6] test: fix memory leak in reorder autotest Anatoly Burakov
@ 2018-02-06 13:35     ` Anatoly Burakov
  2018-02-06 13:35     ` [dpdk-dev] [PATCH v5 4/6] test: fix memory leak in ring perf autotest Anatoly Burakov
                       ` (2 subsequent siblings)
  5 siblings, 0 replies; 47+ messages in thread
From: Anatoly Burakov @ 2018-02-06 13:35 UTC (permalink / raw)
  To: dev; +Cc: Olivier Matz, pablo.de.lara.guarch, stable

Get rid of global static ring variable and don't reuse rings
between test runs.

Acked-by: Olivier Matz <olivier.matz@6wind.com>

Fixes: 4e32101f9b01 ("ring: support freeing")
Cc: pablo.de.lara.guarch@intel.com
Cc: stable@dpdk.org
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---

Notes:
    v5: fix use of uninitialized pointer
    v3: fix commit message to point to approriate commit being fixed
    v2: remove static ring variable

 test/test/test_ring.c | 63 +++++++++++++++++++++++++++------------------------
 1 file changed, 34 insertions(+), 29 deletions(-)

diff --git a/test/test/test_ring.c b/test/test/test_ring.c
index 19d497a..aaf1e70 100644
--- a/test/test/test_ring.c
+++ b/test/test/test_ring.c
@@ -57,8 +57,6 @@
 
 static rte_atomic32_t synchro;
 
-static struct rte_ring *r;
-
 #define	TEST_RING_VERIFY(exp)						\
 	if (!(exp)) {							\
 		printf("error at %s:%d\tcondition " #exp " failed\n",	\
@@ -73,7 +71,7 @@ static struct rte_ring *r;
  * helper routine for test_ring_basic
  */
 static int
-test_ring_basic_full_empty(void * const src[], void *dst[])
+test_ring_basic_full_empty(struct rte_ring *r, void * const src[], void *dst[])
 {
 	unsigned i, rand;
 	const unsigned rsz = RING_SIZE - 1;
@@ -114,7 +112,7 @@ test_ring_basic_full_empty(void * const src[], void *dst[])
 }
 
 static int
-test_ring_basic(void)
+test_ring_basic(struct rte_ring *r)
 {
 	void **src = NULL, **cur_src = NULL, **dst = NULL, **cur_dst = NULL;
 	int ret;
@@ -250,7 +248,7 @@ test_ring_basic(void)
 		goto fail;
 	}
 
-	if (test_ring_basic_full_empty(src, dst) != 0)
+	if (test_ring_basic_full_empty(r, src, dst) != 0)
 		goto fail;
 
 	cur_src = src;
@@ -317,7 +315,7 @@ test_ring_basic(void)
 }
 
 static int
-test_ring_burst_basic(void)
+test_ring_burst_basic(struct rte_ring *r)
 {
 	void **src = NULL, **cur_src = NULL, **dst = NULL, **cur_dst = NULL;
 	int ret;
@@ -671,7 +669,7 @@ test_ring_basic_ex(void)
 {
 	int ret = -1;
 	unsigned i;
-	struct rte_ring * rp;
+	struct rte_ring *rp = NULL;
 	void **obj = NULL;
 
 	obj = rte_calloc("test_ring_basic_ex_malloc", RING_SIZE, sizeof(void *), 0);
@@ -731,6 +729,7 @@ test_ring_basic_ex(void)
 
 	ret = 0;
 fail_test:
+	rte_ring_free(rp);
 	if (obj != NULL)
 		rte_free(obj);
 
@@ -811,61 +810,67 @@ test_ring_with_exact_size(void)
 static int
 test_ring(void)
 {
+	struct rte_ring *r = NULL;
+
 	/* some more basic operations */
 	if (test_ring_basic_ex() < 0)
-		return -1;
+		goto test_fail;
 
 	rte_atomic32_init(&synchro);
 
+	r = rte_ring_create("test", RING_SIZE, SOCKET_ID_ANY, 0);
 	if (r == NULL)
-		r = rte_ring_create("test", RING_SIZE, SOCKET_ID_ANY, 0);
-	if (r == NULL)
-		return -1;
+		goto test_fail;
 
 	/* retrieve the ring from its name */
 	if (rte_ring_lookup("test") != r) {
 		printf("Cannot lookup ring from its name\n");
-		return -1;
+		goto test_fail;
 	}
 
 	/* burst operations */
-	if (test_ring_burst_basic() < 0)
-		return -1;
+	if (test_ring_burst_basic(r) < 0)
+		goto test_fail;
 
 	/* basic operations */
-	if (test_ring_basic() < 0)
-		return -1;
+	if (test_ring_basic(r) < 0)
+		goto test_fail;
 
 	/* basic operations */
 	if ( test_create_count_odd() < 0){
-			printf ("Test failed to detect odd count\n");
-			return -1;
-		}
-		else
-			printf ( "Test detected odd count\n");
+		printf("Test failed to detect odd count\n");
+		goto test_fail;
+	} else
+		printf("Test detected odd count\n");
 
 	if ( test_lookup_null() < 0){
-				printf ("Test failed to detect NULL ring lookup\n");
-				return -1;
-			}
-			else
-				printf ( "Test detected NULL ring lookup \n");
+		printf("Test failed to detect NULL ring lookup\n");
+		goto test_fail;
+	} else
+		printf("Test detected NULL ring lookup\n");
 
 	/* test of creating ring with wrong size */
 	if (test_ring_creation_with_wrong_size() < 0)
-		return -1;
+		goto test_fail;
 
 	/* test of creation ring with an used name */
 	if (test_ring_creation_with_an_used_name() < 0)
-		return -1;
+		goto test_fail;
 
 	if (test_ring_with_exact_size() < 0)
-		return -1;
+		goto test_fail;
 
 	/* dump the ring status */
 	rte_ring_list_dump(stdout);
 
+	rte_ring_free(r);
+
 	return 0;
+
+test_fail:
+	rte_ring_free(r);
+
+	return -1;
 }
 
 REGISTER_TEST_COMMAND(ring_autotest, test_ring);
-- 
2.7.4

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [dpdk-dev] [PATCH v5 4/6] test: fix memory leak in ring perf autotest
  2018-02-05 13:03   ` [dpdk-dev] [PATCH v4 " Anatoly Burakov
                       ` (2 preceding siblings ...)
  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     ` 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
  5 siblings, 0 replies; 47+ messages in thread
From: Anatoly Burakov @ 2018-02-06 13:35 UTC (permalink / raw)
  To: dev; +Cc: Olivier Matz, stable

Acked-by: Olivier Matz <olivier.matz@6wind.com>

Fixes: ac3fb3019c52 ("app: rework ring tests")
Cc: stable@dpdk.org
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.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

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [dpdk-dev] [PATCH v5 5/6] test: fix memory leak in table autotest
  2018-02-05 13:03   ` [dpdk-dev] [PATCH v4 " Anatoly Burakov
                       ` (3 preceding siblings ...)
  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     ` Anatoly Burakov
  2018-02-06 13:35     ` [dpdk-dev] [PATCH v5 6/6] test: fix memory leak in timer perf autotest Anatoly Burakov
  5 siblings, 0 replies; 47+ messages in thread
From: Anatoly Burakov @ 2018-02-06 13:35 UTC (permalink / raw)
  To: dev; +Cc: Cristian Dumitrescu, stable

Always deallocate allocated resources after the test is done.

Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>

Fixes: 5205954791cb ("app/test: packet framework unit tests")
Cc: cristian.dumitrescu@intel.com
Cc: stable@dpdk.org
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---

Notes:
    v4: put ack after signoff

 test/test/test_table.c | 44 ++++++++++++++++++++++++++++----------------
 1 file changed, 28 insertions(+), 16 deletions(-)

diff --git a/test/test/test_table.c b/test/test/test_table.c
index c9268a3..f01652d 100644
--- a/test/test/test_table.c
+++ b/test/test/test_table.c
@@ -55,6 +55,14 @@ uint64_t pipeline_test_hash(void *key,
 }
 
 static void
+app_free_resources(void) {
+	int i;
+	for (i = 0; i < N_PORTS; i++)
+		rte_ring_free(rings_rx[i]);
+	rte_mempool_free(pool);
+}
+
+static void
 app_init_mbuf_pools(void)
 {
 	/* Init the buffer pool */
@@ -113,18 +121,20 @@ app_init_rings(void)
 static int
 test_table(void)
 {
-	int status, failures;
+	int status, ret;
 	unsigned i;
 
-	failures = 0;
+	ret = TEST_SUCCESS;
 
 	app_init_rings();
 	app_init_mbuf_pools();
 
 	printf("\n\n\n\n************Pipeline tests************\n");
 
-	if (test_table_pipeline() < 0)
-		return -1;
+	if (test_table_pipeline() < 0) {
+		ret = TEST_FAILED;
+		goto end;
+	}
 
 	printf("\n\n\n\n************Port tests************\n");
 	for (i = 0; i < n_port_tests; i++) {
@@ -132,8 +142,8 @@ test_table(void)
 		if (status < 0) {
 			printf("\nPort test number %d failed (%d).\n", i,
 				status);
-			failures++;
-			return -1;
+			ret = TEST_FAILED;
+			goto end;
 		}
 	}
 
@@ -143,8 +153,8 @@ test_table(void)
 		if (status < 0) {
 			printf("\nTable test number %d failed (%d).\n", i,
 				status);
-			failures++;
-			return -1;
+			ret = TEST_FAILED;
+			goto end;
 		}
 	}
 
@@ -154,21 +164,23 @@ test_table(void)
 		if (status < 0) {
 			printf("\nCombined table test number %d failed with "
 				"reason number %d.\n", i, status);
-			failures++;
-			return -1;
+			ret = TEST_FAILED;
+			goto end;
 		}
 	}
 
-	if (failures)
-		return -1;
-
 #ifdef RTE_LIBRTE_ACL
 	printf("\n\n\n\n************ACL tests************\n");
-	if (test_table_acl() < 0)
-		return -1;
+	if (test_table_acl() < 0) {
+		ret = TEST_FAILED;
+		goto end;
+	}
 #endif
 
-	return 0;
+end:
+	app_free_resources();
+
+	return ret;
 }
 
 REGISTER_TEST_COMMAND(table_autotest, test_table);
-- 
2.7.4

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [dpdk-dev] [PATCH v5 6/6] test: fix memory leak in timer perf autotest
  2018-02-05 13:03   ` [dpdk-dev] [PATCH v4 " Anatoly Burakov
                       ` (4 preceding siblings ...)
  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     ` Anatoly Burakov
  5 siblings, 0 replies; 47+ messages in thread
From: Anatoly Burakov @ 2018-02-06 13:35 UTC (permalink / raw)
  To: dev; +Cc: Robert Sanford, stable

Fixes: 277afaf3dbcb ("app/test: add timer_perf")
Cc: stable@dpdk.org
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 test/test/test_timer_perf.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/test/test/test_timer_perf.c b/test/test/test_timer_perf.c
index afa3a06..0fe2b74 100644
--- a/test/test/test_timer_perf.c
+++ b/test/test/test_timer_perf.c
@@ -127,6 +127,7 @@ test_timer_perf(void)
 	printf("Time per rte_timer_manage with zero callbacks: %"PRIu64" cycles\n",
 			(end_tsc - start_tsc + iterations/2) / iterations);
 
+	rte_free(tms);
 	return 0;
 }
 
-- 
2.7.4

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [dpdk-dev] [PATCH v5 1/6] test: fix memory leak in bitmap test
  2018-02-06 13:35     ` [dpdk-dev] [PATCH v5 " Anatoly Burakov
@ 2018-02-06 18:34       ` Thomas Monjalon
  0 siblings, 0 replies; 47+ messages in thread
From: Thomas Monjalon @ 2018-02-06 18:34 UTC (permalink / raw)
  To: Anatoly Burakov; +Cc: dev, Cristian Dumitrescu, pbhagavatula

06/02/2018 14:35, Anatoly Burakov:
> Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
> 
> Fixes: c7e4a134e769 ("test: verify bitmap operations")
> Cc: pbhagavatula@caviumnetworks.com
> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>

Series applied, thanks

^ permalink raw reply	[flat|nested] 47+ messages in thread

end of thread, other threads:[~2018-02-06 18:34 UTC | newest]

Thread overview: 47+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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   ` [dpdk-dev] [PATCH v4 4/6] test: fix memory leak in ring perf autotest Anatoly Burakov
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

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).