[v2] test/func_reentrancy: free memzones after creating test case

Message ID 20210731120336.30886-1-joyce.kong@arm.com (mailing list archive)
State Superseded, archived
Delegated to: David Marchand
Headers
Series [v2] test/func_reentrancy: free memzones after creating test case |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/github-robot success github build: passed
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-testing fail Testing issues
ci/iol-abi-testing success Testing PASS

Commit Message

Joyce Kong July 31, 2021, 12:03 p.m. UTC
  Function reentrancy test limits maximum number of iterations
simultaneously, however it doesn't free the 'fr_test_once'
memzones after the fact, so introduce freeing 'fr_test_once'
in ring/mempool/hash/fbk/lpm_clean.

Meanwhile, add the missing free for test case on main thread.

Fixes: 104a92bd026f ("app: add reentrancy tests")
Fixes: 995eec619024 ("test: clean up memory for function reentrancy test")
Cc: stable@dpdk.org

Signed-off-by: Joyce Kong <joyce.kong@arm.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
Reviewed-by: Feifei Wang <feifei.wang2@arm.com>
---
 app/test/test_func_reentrancy.c | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)
  

Comments

David Marchand Aug. 17, 2021, 8:17 a.m. UTC | #1
On Sat, Jul 31, 2021 at 2:04 PM Joyce Kong <joyce.kong@arm.com> wrote:
>
> Function reentrancy test limits maximum number of iterations
> simultaneously, however it doesn't free the 'fr_test_once'
> memzones after the fact, so introduce freeing 'fr_test_once'
> in ring/mempool/hash/fbk/lpm_clean.
>
> Meanwhile, add the missing free for test case on main thread.
>
> Fixes: 104a92bd026f ("app: add reentrancy tests")
> Fixes: 995eec619024 ("test: clean up memory for function reentrancy test")
> Cc: stable@dpdk.org
>
> Signed-off-by: Joyce Kong <joyce.kong@arm.com>
> Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
> Reviewed-by: Feifei Wang <feifei.wang2@arm.com>

This patch actually breaks the test (we are lucky, the failure happens
often ;)).

28/94 DPDK:fast-tests / func_reentrancy_autotest       FAIL
0.22s (exit status 255 or signal 127 SIGinvalid)

--- command ---
16:13:45 DPDK_TEST='func_reentrancy_autotest'
/home-local/jenkins-local/jenkins-agent/workspace/Generic-Unit-Test-DPDK/dpdk/build/app/test/dpdk-test
-l 0-15 --file-prefix=func_reentrancy_autotest
--- stdout ---
RTE>>func_reentrancy_autotest
Func-ReEnt CASE 0: eal init once PASS
ring create/lookup: common object allocated 2 times (should be 1)
Func-ReEnt CASE 1: ring create/lookup FAIL
Test Failed
RTE>>
--- stderr ---


I guess, this is what happens:

main lcore                          worker lcore 1              ...
worker lcore X
                                    enters ring_create_lookup()

enters ring_create_lookup()
rte_eal_wait_lcore(worker lcore 1);
                                    leaves ring_create_lookup()
ring_clean(worker lcore 1);

leaves ring_create_lookup()

There is no synchronisation point for the main lcore to know the
worker lcores are finished invoking the func callback.
With this patch, the "common" object is freed by the main lcore
*potentially* before some workers start trying to create it.
And we end up with multiple workers successfully creating this object,
hence the obj_count being incremented.
  
Joyce Kong Aug. 20, 2021, 7:57 a.m. UTC | #2
> -----Original Message-----
> From: David Marchand <david.marchand@redhat.com>
> Sent: Tuesday, August 17, 2021 4:17 PM
> To: Joyce Kong <Joyce.Kong@arm.com>
> Cc: Burakov, Anatoly <anatoly.burakov@intel.com>; Olivier Matz
> <olivier.matz@6wind.com>; Andrew Rybchenko
> <andrew.rybchenko@oktetlabs.ru>; Wang, Yipeng1
> <yipeng1.wang@intel.com>; Gobriel, Sameh <sameh.gobriel@intel.com>;
> Bruce Richardson <bruce.richardson@intel.com>; Vladimir Medvedkin
> <vladimir.medvedkin@intel.com>; Ananyev, Konstantin
> <konstantin.ananyev@intel.com>; Honnappa Nagarahalli
> <Honnappa.Nagarahalli@arm.com>; Ruifeng Wang
> <Ruifeng.Wang@arm.com>; dev <dev@dpdk.org>; nd <nd@arm.com>; dpdk
> stable <stable@dpdk.org>; Aaron Conole <aconole@redhat.com>
> Subject: Re: [dpdk-dev] [PATCH v2] test/func_reentrancy: free memzones
> after creating test case
> 
> On Sat, Jul 31, 2021 at 2:04 PM Joyce Kong <joyce.kong@arm.com> wrote:
> >
> > Function reentrancy test limits maximum number of iterations
> > simultaneously, however it doesn't free the 'fr_test_once'
> > memzones after the fact, so introduce freeing 'fr_test_once'
> > in ring/mempool/hash/fbk/lpm_clean.
> >
> > Meanwhile, add the missing free for test case on main thread.
> >
> > Fixes: 104a92bd026f ("app: add reentrancy tests")
> > Fixes: 995eec619024 ("test: clean up memory for function reentrancy
> > test")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Joyce Kong <joyce.kong@arm.com>
> > Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
> > Reviewed-by: Feifei Wang <feifei.wang2@arm.com>
> 
> This patch actually breaks the test (we are lucky, the failure happens often ;)).
> 
> 28/94 DPDK:fast-tests / func_reentrancy_autotest       FAIL
> 0.22s (exit status 255 or signal 127 SIGinvalid)
> 
> --- command ---
> 16:13:45 DPDK_TEST='func_reentrancy_autotest'
> /home-local/jenkins-local/jenkins-agent/workspace/Generic-Unit-Test-
> DPDK/dpdk/build/app/test/dpdk-test
> -l 0-15 --file-prefix=func_reentrancy_autotest
> --- stdout ---
> RTE>>func_reentrancy_autotest
> Func-ReEnt CASE 0: eal init once PASS
> ring create/lookup: common object allocated 2 times (should be 1) Func-
> ReEnt CASE 1: ring create/lookup FAIL Test Failed
> RTE>>
> --- stderr ---
> 
> 
> I guess, this is what happens:
> 
> main lcore                          worker lcore 1              ...
> worker lcore X
>                                     enters ring_create_lookup()
> 
> enters ring_create_lookup()
> rte_eal_wait_lcore(worker lcore 1);
>                                     leaves ring_create_lookup() ring_clean(worker lcore 1);
> 
> leaves ring_create_lookup()
> 
> There is no synchronisation point for the main lcore to know the worker
> lcores are finished invoking the func callback.
> With this patch, the "common" object is freed by the main lcore
> *potentially* before some workers start trying to create it.
> And we end up with multiple workers successfully creating this object, hence
> the obj_count being incremented.
> 
> 
> --
> David Marchand

I think add rte_eal_mp_wait_lcore() like below can ensure the lcores to free objects
after all func callback finished.
Shall do the change in next version.

	RTE_LCORE_FOREACH_WORKER(lcore_id) {
		if (cores == 1)
			break;
		cores--;
		rte_eal_remote_launch(pt_case->func, pt_case->arg, lcore_id);
	}
	rte_atomic32_set(&synchro, 1);
	if (pt_case->func(pt_case->arg) < 0)
		ret = -1;

+	rte_eal_mp_wait_lcore();

	cores = cores_save;
	RTE_LCORE_FOREACH_WORKER(lcore_id) {
		if (cores == 1)
			break;
		cores--;
-		if (rte_eal_wait_lcore(lcore_id) < 0)
-			ret = -1;
		if (pt_case->clean != NULL)
			pt_case->clean(lcore_id);
	}
  
David Marchand Aug. 20, 2021, 8:52 a.m. UTC | #3
On Fri, Aug 20, 2021 at 9:57 AM Joyce Kong <Joyce.Kong@arm.com> wrote:
>
> > -----Original Message-----
> > From: David Marchand <david.marchand@redhat.com>
> > Sent: Tuesday, August 17, 2021 4:17 PM
> > To: Joyce Kong <Joyce.Kong@arm.com>
> > Cc: Burakov, Anatoly <anatoly.burakov@intel.com>; Olivier Matz
> > <olivier.matz@6wind.com>; Andrew Rybchenko
> > <andrew.rybchenko@oktetlabs.ru>; Wang, Yipeng1
> > <yipeng1.wang@intel.com>; Gobriel, Sameh <sameh.gobriel@intel.com>;
> > Bruce Richardson <bruce.richardson@intel.com>; Vladimir Medvedkin
> > <vladimir.medvedkin@intel.com>; Ananyev, Konstantin
> > <konstantin.ananyev@intel.com>; Honnappa Nagarahalli
> > <Honnappa.Nagarahalli@arm.com>; Ruifeng Wang
> > <Ruifeng.Wang@arm.com>; dev <dev@dpdk.org>; nd <nd@arm.com>; dpdk
> > stable <stable@dpdk.org>; Aaron Conole <aconole@redhat.com>
> > Subject: Re: [dpdk-dev] [PATCH v2] test/func_reentrancy: free memzones
> > after creating test case
> >
> > On Sat, Jul 31, 2021 at 2:04 PM Joyce Kong <joyce.kong@arm.com> wrote:
> > >
> > > Function reentrancy test limits maximum number of iterations
> > > simultaneously, however it doesn't free the 'fr_test_once'
> > > memzones after the fact, so introduce freeing 'fr_test_once'
> > > in ring/mempool/hash/fbk/lpm_clean.
> > >
> > > Meanwhile, add the missing free for test case on main thread.
> > >
> > > Fixes: 104a92bd026f ("app: add reentrancy tests")
> > > Fixes: 995eec619024 ("test: clean up memory for function reentrancy
> > > test")
> > > Cc: stable@dpdk.org
> > >
> > > Signed-off-by: Joyce Kong <joyce.kong@arm.com>
> > > Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
> > > Reviewed-by: Feifei Wang <feifei.wang2@arm.com>
> >
> > This patch actually breaks the test (we are lucky, the failure happens often ;)).
> >
> > 28/94 DPDK:fast-tests / func_reentrancy_autotest       FAIL
> > 0.22s (exit status 255 or signal 127 SIGinvalid)
> >
> > --- command ---
> > 16:13:45 DPDK_TEST='func_reentrancy_autotest'
> > /home-local/jenkins-local/jenkins-agent/workspace/Generic-Unit-Test-
> > DPDK/dpdk/build/app/test/dpdk-test
> > -l 0-15 --file-prefix=func_reentrancy_autotest
> > --- stdout ---
> > RTE>>func_reentrancy_autotest
> > Func-ReEnt CASE 0: eal init once PASS
> > ring create/lookup: common object allocated 2 times (should be 1) Func-
> > ReEnt CASE 1: ring create/lookup FAIL Test Failed
> > RTE>>
> > --- stderr ---
> >
> >
> > I guess, this is what happens:
> >
> > main lcore                          worker lcore 1              ...
> > worker lcore X
> >                                     enters ring_create_lookup()
> >
> > enters ring_create_lookup()
> > rte_eal_wait_lcore(worker lcore 1);
> >                                     leaves ring_create_lookup() ring_clean(worker lcore 1);
> >
> > leaves ring_create_lookup()
> >
> > There is no synchronisation point for the main lcore to know the worker
> > lcores are finished invoking the func callback.
> > With this patch, the "common" object is freed by the main lcore
> > *potentially* before some workers start trying to create it.
> > And we end up with multiple workers successfully creating this object, hence
> > the obj_count being incremented.
> >
> >
> > --
> > David Marchand
>
> I think add rte_eal_mp_wait_lcore() like below can ensure the lcores to free objects
> after all func callback finished.
> Shall do the change in next version.
>
>         RTE_LCORE_FOREACH_WORKER(lcore_id) {
>                 if (cores == 1)
>                         break;
>                 cores--;
>                 rte_eal_remote_launch(pt_case->func, pt_case->arg, lcore_id);
>         }
>         rte_atomic32_set(&synchro, 1);
>         if (pt_case->func(pt_case->arg) < 0)
>                 ret = -1;
>
> +       rte_eal_mp_wait_lcore();
>
>         cores = cores_save;
>         RTE_LCORE_FOREACH_WORKER(lcore_id) {
>                 if (cores == 1)
>                         break;
>                 cores--;
> -               if (rte_eal_wait_lcore(lcore_id) < 0)
> -                       ret = -1;
>                 if (pt_case->clean != NULL)
>                         pt_case->clean(lcore_id);
>         }

Using mp_wait_lcore, the test can't tell if a lcore returned an error
after executing the passed callback.

An alternative is to split the current loop to first have the per
lcore rte_eal_wait_lcore() calls + ret code check, and then a second
loop calls the clean() callback.
  
Joyce Kong Aug. 23, 2021, 2:25 a.m. UTC | #4
<snip>

> > > Subject: Re: [dpdk-dev] [PATCH v2] test/func_reentrancy: free
> > > memzones after creating test case
> > >
> > > On Sat, Jul 31, 2021 at 2:04 PM Joyce Kong <joyce.kong@arm.com> wrote:
> > > >
> > > > Function reentrancy test limits maximum number of iterations
> > > > simultaneously, however it doesn't free the 'fr_test_once'
> > > > memzones after the fact, so introduce freeing 'fr_test_once'
> > > > in ring/mempool/hash/fbk/lpm_clean.
> > > >
> > > > Meanwhile, add the missing free for test case on main thread.
> > > >
> > > > Fixes: 104a92bd026f ("app: add reentrancy tests")
> > > > Fixes: 995eec619024 ("test: clean up memory for function
> > > > reentrancy
> > > > test")
> > > > Cc: stable@dpdk.org
> > > >
> > > > Signed-off-by: Joyce Kong <joyce.kong@arm.com>
> > > > Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
> > > > Reviewed-by: Feifei Wang <feifei.wang2@arm.com>
> > >
> > > This patch actually breaks the test (we are lucky, the failure happens
> often ;)).
> > >
> > > 28/94 DPDK:fast-tests / func_reentrancy_autotest       FAIL
> > > 0.22s (exit status 255 or signal 127 SIGinvalid)
> > >
> > > --- command ---
> > > 16:13:45 DPDK_TEST='func_reentrancy_autotest'
> > > /home-local/jenkins-local/jenkins-agent/workspace/Generic-Unit-Test-
> > > DPDK/dpdk/build/app/test/dpdk-test
> > > -l 0-15 --file-prefix=func_reentrancy_autotest
> > > --- stdout ---
> > > RTE>>func_reentrancy_autotest
> > > Func-ReEnt CASE 0: eal init once PASS ring create/lookup: common
> > > object allocated 2 times (should be 1) Func- ReEnt CASE 1: ring
> > > create/lookup FAIL Test Failed
> > > RTE>>
> > > --- stderr ---
> > >
> > >
> > > I guess, this is what happens:
> > >
> > > main lcore                          worker lcore 1              ...
> > > worker lcore X
> > >                                     enters ring_create_lookup()
> > >
> > > enters ring_create_lookup()
> > > rte_eal_wait_lcore(worker lcore 1);
> > >                                     leaves ring_create_lookup()
> > > ring_clean(worker lcore 1);
> > >
> > > leaves ring_create_lookup()
> > >
> > > There is no synchronisation point for the main lcore to know the
> > > worker lcores are finished invoking the func callback.
> > > With this patch, the "common" object is freed by the main lcore
> > > *potentially* before some workers start trying to create it.
> > > And we end up with multiple workers successfully creating this
> > > object, hence the obj_count being incremented.
> > >
> > >
> > > --
> > > David Marchand
> >
> > I think add rte_eal_mp_wait_lcore() like below can ensure the lcores
> > to free objects after all func callback finished.
> > Shall do the change in next version.
> >
> >         RTE_LCORE_FOREACH_WORKER(lcore_id) {
> >                 if (cores == 1)
> >                         break;
> >                 cores--;
> >                 rte_eal_remote_launch(pt_case->func, pt_case->arg, lcore_id);
> >         }
> >         rte_atomic32_set(&synchro, 1);
> >         if (pt_case->func(pt_case->arg) < 0)
> >                 ret = -1;
> >
> > +       rte_eal_mp_wait_lcore();
> >
> >         cores = cores_save;
> >         RTE_LCORE_FOREACH_WORKER(lcore_id) {
> >                 if (cores == 1)
> >                         break;
> >                 cores--;
> > -               if (rte_eal_wait_lcore(lcore_id) < 0)
> > -                       ret = -1;
> >                 if (pt_case->clean != NULL)
> >                         pt_case->clean(lcore_id);
> >         }
> 
> Using mp_wait_lcore, the test can't tell if a lcore returned an error after
> executing the passed callback.
> 
> An alternative is to split the current loop to first have the per lcore
> rte_eal_wait_lcore() calls + ret code check, and then a second loop calls the
> clean() callback.
> 
> 
> --
> David Marchand

Hi, David, thanks for your suggestion, will send a new version with this modification.

--
Joyce
  

Patch

diff --git a/app/test/test_func_reentrancy.c b/app/test/test_func_reentrancy.c
index 231c99a9eb..e4e9c2cc7c 100644
--- a/app/test/test_func_reentrancy.c
+++ b/app/test/test_func_reentrancy.c
@@ -89,6 +89,10 @@  ring_clean(unsigned int lcore_id)
 	char ring_name[MAX_STRING_SIZE];
 	int i;
 
+	rp = rte_ring_lookup("fr_test_once");
+	if (rp != NULL)
+		rte_ring_free(rp);
+
 	for (i = 0; i < MAX_ITER_MULTI; i++) {
 		snprintf(ring_name, sizeof(ring_name),
 				"fr_test_%d_%d", lcore_id, i);
@@ -148,7 +152,10 @@  mempool_clean(unsigned int lcore_id)
 	char mempool_name[MAX_STRING_SIZE];
 	int i;
 
-	/* verify all ring created successful */
+	mp = rte_mempool_lookup("fr_test_once");
+	if (mp != NULL)
+		rte_mempool_free(mp);
+
 	for (i = 0; i < MAX_ITER_MULTI; i++) {
 		snprintf(mempool_name, sizeof(mempool_name), "fr_test_%d_%d",
 			 lcore_id, i);
@@ -208,6 +215,10 @@  hash_clean(unsigned lcore_id)
 	struct rte_hash *handle;
 	int i;
 
+	handle = rte_hash_find_existing("fr_test_once");
+	if (handle != NULL)
+		rte_hash_free(handle);
+
 	for (i = 0; i < MAX_ITER_MULTI; i++) {
 		snprintf(hash_name, sizeof(hash_name), "fr_test_%d_%d",  lcore_id, i);
 
@@ -272,6 +283,10 @@  fbk_clean(unsigned lcore_id)
 	struct rte_fbk_hash_table *handle;
 	int i;
 
+	handle = rte_fbk_hash_find_existing("fr_test_once");
+	if (handle != NULL)
+		rte_fbk_hash_free(handle);
+
 	for (i = 0; i < MAX_ITER_MULTI; i++) {
 		snprintf(fbk_name, sizeof(fbk_name), "fr_test_%d_%d",  lcore_id, i);
 
@@ -338,6 +353,10 @@  lpm_clean(unsigned int lcore_id)
 	struct rte_lpm *lpm;
 	int i;
 
+	lpm = rte_lpm_find_existing("fr_test_once");
+	if (lpm != NULL)
+		rte_lpm_free(lpm);
+
 	for (i = 0; i < MAX_LPM_ITER_TIMES; i++) {
 		snprintf(lpm_name, sizeof(lpm_name), "fr_test_%d_%d",  lcore_id, i);
 
@@ -454,6 +473,9 @@  launch_test(struct test_case *pt_case)
 			pt_case->clean(lcore_id);
 	}
 
+	if (pt_case->clean != NULL)
+		pt_case->clean(rte_get_main_lcore());
+
 	count = rte_atomic32_read(&obj_count);
 	if (count != 1) {
 		printf("%s: common object allocated %d times (should be 1)\n",