test/func_reentrancy: free memzones after creating test case
PATCH 1/1 test/func_reentrancy: free memzones after creating test case
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.
--- app/test/test_func_reentrancy.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-)
app/test/test_func_reentrancy.c +23 -1
@@ -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",
Signature · 1 line
2.17.1
Hi Joyce,
Quoted 77 lines · Joyce Kong
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.Fixes 104a92bd026f ("app: add reentrancy tests")Fixes 995eec619024 ("test: clean up memory for function reentrancy test")Signed-off-by Joyce Kong <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>Reviewed-by Feifei Wang <[email protected]>--- app/test/test_func_reentrancy.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-)app/test/test_func_reentrancy.c +20
-1@@ -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);
app/test/test_func_reentrancy.c launch_test(struct test_case *pt_case) · line 478
Quoted 6 lines
app/test/test_func_reentrancy.c +3
-0@@ -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 ()); +
Is it the same issue? It looks it adds the missing frees for the main thread (not only "fr_test_once"). I don't think it requires another patch, but a word could be added about it in the commit log.
Quoted 6 lines
app/test/test_func_reentrancy.c +0
-0count =rte_atomic32_read (&obj_count);if (count !=1 ) { printf("%s: common object allocated %d times (should be 1)\n",Signature · 1 line
2.17.1
Quoted 107 lines
-----Original Message-----
From: Olivier Matz <[email protected]>
Sent: Friday, July 30, 2021 7:27 PM
To: Joyce Kong <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Honnappa Nagarahalli <[email protected]>; Ruifeng Wang <[email protected]>; [email protected]; nd <[email protected]>; [email protected]
Subject: Re: [PATCH v1] test/func_reentrancy: free memzones after creating test caseHi Joyce,
Quoted 33 lines · Joyce Kong
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.Fixes 104a92bd026f ("app: add reentrancy tests")Fixes 995eec619024 ("test: clean up memory for function reentrancytest")
Cc: [email protected]Signed-off-by Joyce Kong <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>Reviewed-by Feifei Wang <[email protected]>--- app/test/test_func_reentrancy.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-)(quoted diff) +0
-0
b/app/test/test_func_reentrancy.cindex231c99a9eb..e4e9c2cc7c100644app/test/test_func_reentrancy.c +4
-0@@ -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);app/test/test_func_reentrancy.c mempool_clean(unsigned int lcore_id) · line 160
Quoted 10 lines
app/test/test_func_reentrancy.c +4
-1@@ -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",
app/test/test_func_reentrancy.c hash_clean(unsigned lcore_id) · line 223
Quoted 11 lines
app/test/test_func_reentrancy.c +4
-0lcore_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,app/test/test_func_reentrancy.c fbk_clean(unsigned lcore_id) · line 291
Quoted 12 lines
app/test/test_func_reentrancy.c +4
-0i);@@ -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,app/test/test_func_reentrancy.c lpm_clean(unsigned int lcore_id) · line 361
Quoted 12 lines
app/test/test_func_reentrancy.c +4
-0i);@@ -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,Quoted 6 lines
app/test/test_func_reentrancy.c +0
-0i);@@ -454,6 +473,9 @@ launch_test(struct test_case *pt_case) pt_case->clean (lcore_id); }
Quoted 8 lines
app/test/test_func_reentrancy.c launch_test(struct test_case *pt_case) · line 478
Quoted 3 lines
app/test/test_func_reentrancy.c +3
-0+if (pt_case->clean !=NULL ) + pt_case->clean (rte_get_main_lcore ()); +Is it the same issue? It looks it adds the missing frees for the main thread (not only "
fr_test_once"). I don't think it requires another patch, but a word could be added about it in the commit log.
Thanks, Olivier, will send another version to add this in the commit log.
Quoted 8 lines
app/test/test_func_reentrancy.c launch_test(struct test_case *pt_case)
Quoted 4 lines
app/test/test_func_reentrancy.c +0
-0count =rte_atomic32_read (&obj_count);if (count !=1 ) { printf("%s: common object allocated %d times (should be1)\n",
Quoted 3 lines
--
2.17.1
PATCH v2 1/1 test/func_reentrancy: free memzones after creating test case
In reply to Joyce KongFunction 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.
--- app/test/test_func_reentrancy.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-)
app/test/test_func_reentrancy.c +23 -1
@@ -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",
Signature · 1 line
2.17.1
Quoted 8 lines · Joyce Kong
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.
Quoted 7 lines
Fixes 104a92bd026f ("app: add reentrancy tests")Fixes 995eec619024 ("test: clean up memory for function reentrancy test")Signed-off-by Joyce Kong <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>Reviewed-by Feifei Wang <[email protected]>
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.
Signature · 1 line
David Marchand
Quoted 74 lines
-----Original Message-----
From: David Marchand <[email protected]>
Sent: Tuesday, August 17, 2021 4:17 PM
To: Joyce Kong <[email protected]>
Cc: Burakov, Anatoly <[email protected]>; Olivier Matz <[email protected]>; Andrew Rybchenko <[email protected]>; Wang, Yipeng1 <[email protected]>; Gobriel, Sameh <[email protected]>; Bruce Richardson <[email protected]>; Vladimir Medvedkin <[email protected]>; Ananyev, Konstantin <[email protected]>; Honnappa Nagarahalli <[email protected]>; Ruifeng Wang <[email protected]>; dev <[email protected]>; nd <[email protected]>; dpdk stable <[email protected]>; Aaron Conole <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v2] test/func_reentrancy: free memzones after creating test caseQuoted 8 lines · Joyce Kong
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.
Quoted 8 lines
Fixes 104a92bd026f ("app: add reentrancy tests")Fixes 995eec619024 ("test: clean up memory for function reentrancytest")
Cc: [email protected]Signed-off-by Joyce Kong <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>Reviewed-by Feifei Wang <[email protected]>This patch actually breaks the test (we are lucky, the failure happens often ;)).
28/94 DPDK:fast-tests /
func_reentrancy_autotestFAIL
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
entersring_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 theobj_countbeing incremented.
Quoted 2 lines
--
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);
}Quoted 94 lines · Joyce Kong
Quoted 75 lines
-----Original Message-----
From: David Marchand <[email protected]>
Sent: Tuesday, August 17, 2021 4:17 PM
To: Joyce Kong <[email protected]>
Cc: Burakov, Anatoly <[email protected]>; Olivier Matz <[email protected]>; Andrew Rybchenko <[email protected]>; Wang, Yipeng1 <[email protected]>; Gobriel, Sameh <[email protected]>; Bruce Richardson <[email protected]>; Vladimir Medvedkin <[email protected]>; Ananyev, Konstantin <[email protected]>; Honnappa Nagarahalli <[email protected]>; Ruifeng Wang <[email protected]>; dev <[email protected]>; nd <[email protected]>; dpdk stable <[email protected]>; Aaron Conole <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v2] test/func_reentrancy: free memzones after creating test caseQuoted 8 lines · Joyce Kong
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.
Quoted 8 lines
Fixes 104a92bd026f ("app: add reentrancy tests")Fixes 995eec619024 ("test: clean up memory for function reentrancytest")
Cc: [email protected]Signed-off-by Joyce Kong <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>Reviewed-by Feifei Wang <[email protected]>This patch actually breaks the test (we are lucky, the failure happens often ;)).
28/94 DPDK:fast-tests /
func_reentrancy_autotestFAIL
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
entersring_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 theobj_countbeing incremented.Quoted 2 lines
--
David MarchandI 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;(quoted diff) +1
-0+ rte_eal_mp_wait_lcore();
Review
Quoted 10 lines
(quoted diff) +0
-2cores = 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.
Signature · 1 line
David Marchand
<snip>
Quoted 96 lines
Quoted 18 lines
Quoted 18 lines
Subject: Re: [dpdk-dev] [PATCH v2] test/func_reentrancy: free memzones after creating test case
Quoted 14 lines · Joyce Kong
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 functionreentrancy
test")
Cc: [email protected]Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Signed-off-by Joyce Kong <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>Reviewed-by Feifei Wang <[email protected]>This patch actually breaks the test (we are lucky, the failure happens
often ;)).
Quoted 58 lines
Quoted 39 lines
28/94 DPDK:fast-tests /
func_reentrancy_autotestFAIL
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
entersring_create_lookup()enters
ring_create_lookup()rte_eal_wait_lcore(worker lcore 1);
leavesring_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_countbeing incremented.Quoted 2 lines
--
David MarchandI 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;(quoted diff) +1
-0+ rte_eal_mp_wait_lcore();Review
Quoted 10 lines
(quoted diff) +0
-2cores = 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.
Quoted 7 lines
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 theclean()callback.--
David Marchand
Hi, David, thanks for your suggestion, will send a new version with this modification.
--
Joyce
PATCH v3 1/1 test/func_reentrancy: free memzones after creating test
In reply to Joyce KongFunction 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.
--- app/test/test_func_reentrancy.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-)
app/test/test_func_reentrancy.c +24 -3
@@ -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);
@@ -441,19 +460,21 @@ launch_test(struct test_case *pt_case)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); } +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",
Signature · 1 line
2.17.1
PATCH v4 1/1 test/func_reentrancy: free memzones after creating test
In reply to Joyce KongFunction 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.
---
v3/v4:
Add the synchronization between the main lcore and worker lcores to ensure lcores to free "common object" after all func callback finished. <David Marchand>
v2:
Add the discription about adding missing frees for the main thread in the commit log. <Olivier Matz>
v1:
The initial version.
--- app/test/test_func_reentrancy.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-)
app/test/test_func_reentrancy.c +23 -7
@@ -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);
@@ -420,8 +439,7 @@ launch_test(struct test_case *pt_case) {int ret =0 ;unsigned lcore_id; -unsigned cores_save =rte_lcore_count (); -unsigned cores =RTE_MIN (cores_save,MAX_LCORES ); +unsigned cores =RTE_MIN (rte_lcore_count (),MAX_LCORES );unsigned count;if (pt_case->func ==NULL )
@@ -442,14 +460,12 @@ launch_test(struct test_case *pt_case)if (pt_case->func (pt_case->arg) <0 ) ret =-1 ; - cores = cores_save;RTE_LCORE_FOREACH_WORKER (lcore_id) { -if (cores ==1 ) -break ; - cores--;if (rte_eal_wait_lcore (lcore_id) <0 ) ret =-1 ; + } +RTE_LCORE_FOREACH (lcore_id) {if (pt_case->clean !=NULL ) pt_case->clean (lcore_id); }
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v4] test/func_reentrancy: free memzones after creating test
Quoted 7 lines · Joyce Kong
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.
Quoted 7 lines
Fixes 104a92bd026f ("app: add reentrancy tests")Fixes 995eec619024 ("test: clean up memory for function reentrancy test")Signed-off-by Joyce Kong <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>Reviewed-by Feifei Wang <[email protected]>
Re: [dpdk-dev] [PATCH v4] test/func_reentrancy: free memzones after creating test
Quoted 9 lines · Olivier Matz
Quoted 7 lines · Joyce Kong
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.
Quoted 8 lines
Quoted 7 lines
Fixes 104a92bd026f ("app: add reentrancy tests")Fixes 995eec619024 ("test: clean up memory for function reentrancy test")Signed-off-by Joyce Kong <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>Reviewed-by Feifei Wang <[email protected]>Reviewed-by Olivier Matz <[email protected]>
Applied, thanks.
Signature · 1 line
David Marchand