test_distributor.c: prevent memory leakages from the pool
PATCH 1/1 test_distributor.c: prevent memory leakages from the pool
rte_mempool_get_bulk is used to get bufs/many_bufs from the pool, but at some locations when test passes/fails the bufs/many_bufs are not returned back to the pool.
Due to this, multiple executions of distributor_autotest gives the following error message: Error getting mbufs from pool. To resolve this issue rte_mempool_put_bulk is used whenever the test passes/fails and returns.
--- app/test/test_distributor.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
app/test/test_distributor.c +13 -0
@@ -128,6 +128,7 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p)printf ("Line %d: Error, not all packets flushed. " "Expected %u, got %u\n" , __LINE__,BURST ,total_packet_count ()); +rte_mempool_put_bulk (p, (void *)bufs,BURST );return -1 ; }
@@ -153,6 +154,7 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p)printf ("Line %d: Error, not all packets flushed. " "Expected %u, got %u\n" , __LINE__,BURST ,total_packet_count ()); +rte_mempool_put_bulk (p, (void *)bufs,BURST );return -1 ; }
@@ -179,6 +181,7 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p)printf ("Line %d: Error, not all packets flushed. " "Expected %u, got %u\n" , __LINE__,BURST ,total_packet_count ()); +rte_mempool_put_bulk (p, (void *)bufs,BURST );return -1 ; }
@@ -233,6 +236,7 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p)if (num_returned !=BIG_BATCH ) {printf ("line %d: Missing packets, expected %d\n" , __LINE__, num_returned); +rte_mempool_put_bulk (p, (void *)many_bufs,BIG_BATCH );return -1 ; }
@@ -247,6 +251,7 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p)if (j ==BIG_BATCH ) {printf ("Error: could not find source packet #%u\n" , i); +rte_mempool_put_bulk (p, (void *)many_bufs,BIG_BATCH );return -1 ; } }
@@ -327,10 +332,12 @@ sanity_test_with_mbuf_alloc(struct worker_params *wp, struct rte_mempool *p)printf ("Line %u: Packet count is incorrect, %u, expected %u\n" , __LINE__,total_packet_count (), (1 <<ITER_POWER )); +rte_mempool_put_bulk (p, (void *)bufs,BURST );return -1 ; }printf ("Sanity test with mbuf alloc/free passed\n\n" ); +rte_mempool_put_bulk (p, (void *)bufs,BURST );return 0 ; }
@@ -450,10 +457,14 @@ sanity_test_with_worker_shutdown(struct worker_params *wp,printf ("Line %d: Error, not all packets flushed. " "Expected %u, got %u\n" , __LINE__,BURST *2 ,total_packet_count ()); +for (i =0 ; i <2 ; i++) +rte_mempool_put_bulk (p, (void *)bufs,BURST );return -1 ; }printf ("Sanity test with worker shutdown passed\n\n" ); +for (i =0 ; i <2 ; i++) +rte_mempool_put_bulk (p, (void *)bufs,BURST );return 0 ; }
@@ -503,10 +514,12 @@ test_flush_with_worker_shutdown(struct worker_params *wp,printf ("Line %d: Error, not all packets flushed. " "Expected %u, got %u\n" , __LINE__,BURST ,total_packet_count ()); +rte_mempool_put_bulk (p, (void *)bufs,BURST );return -1 ; }printf ("Flush test with worker shutdown passed\n\n" ); +rte_mempool_put_bulk (p, (void *)bufs,BURST );return 0 ; }
Signature · 1 line
2.17.1
Hi, Sarosh
I believe commit message title should begin with app/test not the file name
Other comments inline
W dniu 13.04.2020 o 11:19, Sarosh Arif pisze:
Quoted 58 lines
rte_mempool_get_bulkis used to get bufs/many_bufs from the pool, but at some locations when test passes/fails the bufs/many_bufs are not returned back to the pool.
Due to this, multiple executions ofdistributor_autotestgives the following error message: Error getting mbufs from pool. To resolve this issuerte_mempool_put_bulkis used whenever the test passes/fails and returns.Signed-off-by Sarosh Arif <[email protected]>--- app/test/test_distributor.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)app/test/test_distributor.c +5
-0@@ -128,6 +128,7 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p)printf ("Line %d: Error, not all packets flushed. " "Expected %u, got %u\n" , __LINE__,BURST ,total_packet_count ()); +rte_mempool_put_bulk (p, (void *)bufs,BURST );return -1 ; }@@ -153,6 +154,7 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p)printf ("Line %d: Error, not all packets flushed. " "Expected %u, got %u\n" , __LINE__,BURST ,total_packet_count ()); +rte_mempool_put_bulk (p, (void *)bufs,BURST );return -1 ; }@@ -179,6 +181,7 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p)printf ("Line %d: Error, not all packets flushed. " "Expected %u, got %u\n" , __LINE__,BURST ,total_packet_count ()); +rte_mempool_put_bulk (p, (void *)bufs,BURST );return -1 ; }@@ -233,6 +236,7 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p)if (num_returned !=BIG_BATCH ) {printf ("line %d: Missing packets, expected %d\n" , __LINE__, num_returned); +rte_mempool_put_bulk (p, (void *)many_bufs,BIG_BATCH );return -1 ; }@@ -247,6 +251,7 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p)if (j ==BIG_BATCH ) {printf ("Error: could not find source packet #%u\n" , i); +rte_mempool_put_bulk (p, (void *)many_bufs,BIG_BATCH );return -1 ; } }
app/test/test_distributor.c sanity_test_with_mbuf_alloc(struct worker_params *wp, struct rte_mempool *p) · line 335
Quoted 4 lines
app/test/test_distributor.c +1
-0@@ -327,10 +332,12 @@ sanity_test_with_mbuf_alloc(struct worker_params *wp, struct rte_mempool *p)printf ("Line %u: Packet count is incorrect, %u, expected %u\n" , __LINE__,total_packet_count (), (1 <<ITER_POWER )); +rte_mempool_put_bulk (p, (void *)bufs,BURST );
This modification can cause double free of mbufs, as they are freed already with rte_pktmbuf_free in handle_work_with_free_mbufs (line 290). Even if you assume that this condition will be run when not all of the packets were processed by worker, you don't know which were and which were not processed.
Please remove it from your patch.
app/test/test_distributor.c sanity_test_with_mbuf_alloc(struct worker_params *wp, struct rte_mempool *p) · line 340
Quoted 5 lines
app/test/test_distributor.c +1
-0return -1 ; }printf ("Sanity test with mbuf alloc/free passed\n\n" ); +rte_mempool_put_bulk (p, (void *)bufs,BURST );
This modification causes double free of mbufs, as they are freed already with rte_pktmbuf_free in handle_work_with_free_mbufs (line 290). Please remove it from your patch.
app/test/test_distributor.c sanity_test_with_worker_shutdown(struct worker_params *wp, · line 461
Quoted 10 lines
app/test/test_distributor.c +2
-0return 0 ; }@@ -450,10 +457,14 @@ sanity_test_with_worker_shutdown(struct worker_params *wp,printf ("Line %d: Error, not all packets flushed. " "Expected %u, got %u\n" , __LINE__,BURST *2 ,total_packet_count ()); +for (i =0 ; i <2 ; i++) +rte_mempool_put_bulk (p, (void *)bufs,BURST );
This modification can cause double free of mbufs, as they are freed already with rte_pktmbuf_free in handle_work_for_shutdown_test (line 367). Please remove it from your patch.
app/test/test_distributor.c sanity_test_with_worker_shutdown(struct worker_params *wp, · line 467
Quoted 6 lines
app/test/test_distributor.c +2
-0return -1 ; }printf ("Sanity test with worker shutdown passed\n\n" ); +for (i =0 ; i <2 ; i++) +rte_mempool_put_bulk (p, (void *)bufs,BURST );
This modification causes double free of mbufs, as they are freed already with rte_pktmbuf_free in handle_work_for_shutdown_test (line 367). Please remove it from your patch.
app/test/test_distributor.c test_flush_with_worker_shutdown(struct worker_params *wp, · line 517
Quoted 8 lines
app/test/test_distributor.c +1
-0return 0 ; }@@ -503,10 +514,12 @@ test_flush_with_worker_shutdown(struct worker_params *wp,printf ("Line %d: Error, not all packets flushed. " "Expected %u, got %u\n" , __LINE__,BURST ,total_packet_count ()); +rte_mempool_put_bulk (p, (void *)bufs,BURST );
This modification can cause double free of mbufs, as they are freed already with rte_pktmbuf_free in handle_work_for_shutdown_test (line 367). Please remove it from your patch.
app/test/test_distributor.c test_flush_with_worker_shutdown(struct worker_params *wp, · line 522
Quoted 5 lines
app/test/test_distributor.c +1
-0return -1 ; }printf ("Flush test with worker shutdown passed\n\n" ); +rte_mempool_put_bulk (p, (void *)bufs,BURST );
This modification causes double free of mbufs, as they are freed already with rte_pktmbuf_free in handle_work_for_shutdown_test (line 367). Please remove it from your patch.
app/test/test_distributor.c sanity_test_with_mbuf_alloc(struct worker_params *wp, struct rte_mempool *p) · line 343
Quoted 3 lines
app/test/test_distributor.c +0
-0return 0 ; }
Generally there are 3 handlers for workers:
* handle_work
* handle_work_with_free_mbufs
* handle_work_for_shutdown_test
The first one doesn't do anything with mbufs and sens it back to the test, where they should be released.
In the other 2 handlers mbufs are released, so they shouldn't be put back to mempool in test function.
Keeping this simple rules will be the asy way to clean the code and manage pool object properly.
Please consider also, that the there are still few places, where this rules are broken and there is one more tricky place: quit_workers function, which is called in all tests.
You can easily test proper usage of mempool by defining RTE_LIBRTE_MEMPOOL_DEBUG to 1
Signature · 7 lines
Lukasz Wojciechowski Principal Software Engineer Samsung R&D Institute Poland Samsung Electronics Office +48 22 377 88 25 [email protected]
PATCH v2 1/1 app/test/test_distributor.c: prevent memory leakages from the pool
In reply to Sarosh Arifv2:
remove double freeing of mbufs
--- app/test/test_distributor.c | 9 +++++++ 1 file changed, 7 insertions(+)
app/test/test_distributor.c +5 -0
@@ -128,6 +128,7 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p)printf ("Line %d: Error, not all packets flushed. " "Expected %u, got %u\n" , __LINE__,BURST ,total_packet_count ()); +rte_mempool_put_bulk (p, (void *)bufs,BURST );return -1 ; }
@@ -153,6 +154,7 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p)printf ("Line %d: Error, not all packets flushed. " "Expected %u, got %u\n" , __LINE__,BURST ,total_packet_count ()); +rte_mempool_put_bulk (p, (void *)bufs,BURST );return -1 ; }
@@ -179,6 +181,7 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p)printf ("Line %d: Error, not all packets flushed. " "Expected %u, got %u\n" , __LINE__,BURST ,total_packet_count ()); +rte_mempool_put_bulk (p, (void *)bufs,BURST );return -1 ; }
@@ -233,6 +236,7 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p)if (num_returned !=BIG_BATCH ) {printf ("line %d: Missing packets, expected %d\n" , __LINE__, num_returned); +rte_mempool_put_bulk (p, (void *)many_bufs,BIG_BATCH );return -1 ; }
@@ -247,6 +251,7 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p)if (j ==BIG_BATCH ) {printf ("Error: could not find source packet #%u\n" , i); +rte_mempool_put_bulk (p, (void *)many_bufs,BIG_BATCH );return -1 ; } }
2.17.1
Re: [dpdk-dev] [PATCH v2] app/test/test_distributor.c: prevent memory leakages from the pool
W dniu 15.04.2020 o 08:42, Sarosh Arif pisze:
Quoted 53 lines
v2:
remove double freeing of mbufsSigned-off-by Sarosh Arif <[email protected]>--- app/test/test_distributor.c | 9 +++++++ 1 file changed, 7 insertions(+)app/test/test_distributor.c +5
-0@@ -128,6 +128,7 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p)printf ("Line %d: Error, not all packets flushed. " "Expected %u, got %u\n" , __LINE__,BURST ,total_packet_count ()); +rte_mempool_put_bulk (p, (void *)bufs,BURST );return -1 ; }@@ -153,6 +154,7 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p)printf ("Line %d: Error, not all packets flushed. " "Expected %u, got %u\n" , __LINE__,BURST ,total_packet_count ()); +rte_mempool_put_bulk (p, (void *)bufs,BURST );return -1 ; }@@ -179,6 +181,7 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p)printf ("Line %d: Error, not all packets flushed. " "Expected %u, got %u\n" , __LINE__,BURST ,total_packet_count ()); +rte_mempool_put_bulk (p, (void *)bufs,BURST );return -1 ; }@@ -233,6 +236,7 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p)if (num_returned !=BIG_BATCH ) {printf ("line %d: Missing packets, expected %d\n" , __LINE__, num_returned); +rte_mempool_put_bulk (p, (void *)many_bufs,BIG_BATCH );return -1 ; }@@ -247,6 +251,7 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p)if (j ==BIG_BATCH ) {printf ("Error: could not find source packet #%u\n" , i); +rte_mempool_put_bulk (p, (void *)many_bufs,BIG_BATCH );return -1 ; } }
Quoted 2 lines
2.17.1
The sanity_test is ok now and does not have any mempool leaks.
What about other tests in this file: Do you plan to work on them also?
Signature · 7 lines
Lukasz Wojciechowski Principal Software Engineer Samsung R&D Institute Poland Samsung Electronics Office +48 22 377 88 25 [email protected]
Re: [dpdk-dev] [PATCH v2] app/test/test_distributor.c: prevent memory leakages from the pool
Yes, I plan to work on them when I get time.
Quoted 80 lines · Lukasz Wojciechowski
W dniu 15.04.2020 o 08:42, Sarosh Arif pisze:
app/test/test_distributor.c sanity_test(struct worker_params *wp, struct
Quoted 13 lines
v2:
remove double freeing of mbufsSigned-off-by Sarosh Arif <[email protected]>--- app/test/test_distributor.c | 9 +++++++ 1 file changed, 7 insertions(+)app/test/test_distributor.c +0
-0@@ -128,6 +128,7 @@ sanity_test(struct worker_params *wp, struct
rte_mempool*p)app/test/test_distributor.c sanity_test(struct worker_params *wp, struct
Quoted 8 lines
app/test/test_distributor.c +1
-0printf ("Line %d: Error, not all packets flushed. " "Expected %u, got %u\n" , __LINE__,BURST ,total_packet_count ()); +rte_mempool_put_bulk (p, (void *)bufs,BURST );return -1 ; }@@ -153,6 +154,7 @@ sanity_test(struct worker_params *wp, struct
rte_mempool*p)app/test/test_distributor.c sanity_test(struct worker_params *wp, struct rte_mempool *p)
Quoted 3 lines
app/test/test_distributor.c +0
-0printf("Line %d: Error, not all packets flushed. " "Expected %u, got %u\n", __LINE__, BURST,
total_packet_count());app/test/test_distributor.c sanity_test(struct worker_params *wp, struct
Quoted 5 lines
app/test/test_distributor.c +1
-0+rte_mempool_put_bulk (p, (void *)bufs,BURST );return -1 ; }@@ -179,6 +181,7 @@ sanity_test(struct worker_params *wp, struct
rte_mempool*p)app/test/test_distributor.c sanity_test(struct worker_params *wp, struct
Quoted 8 lines
app/test/test_distributor.c +1
-0printf ("Line %d: Error, not all packets flushed. " "Expected %u, got %u\n" , __LINE__,BURST ,total_packet_count ()); +rte_mempool_put_bulk (p, (void *)bufs,BURST );return -1 ; }@@ -233,6 +236,7 @@ sanity_test(struct worker_params *wp, struct
rte_mempool*p)app/test/test_distributor.c sanity_test(struct worker_params *wp, struct
Quoted 8 lines
app/test/test_distributor.c +1
-0if (num_returned !=BIG_BATCH ) {printf ("line %d: Missing packets, expected %d\n" , __LINE__, num_returned); +rte_mempool_put_bulk (p, (void *)many_bufs,BIG_BATCH );return -1 ; }@@ -247,6 +251,7 @@ sanity_test(struct worker_params *wp, struct
rte_mempool*p)app/test/test_distributor.c sanity_test(struct worker_params *wp, struct · line 252
Quoted 3 lines
app/test/test_distributor.c +0
-0if (j ==BIG_BATCH ) { printf("Error: could not find source packet#%u\n", i);
app/test/test_distributor.c sanity_test(struct worker_params *wp, struct · line 253
Quoted 1 line
app/test/test_distributor.c +1
-0+ rte_mempool_put_bulk(p, (void *)many_bufs,
BIG_BATCH);Quoted 6 lines
app/test/test_distributor.c +0
-0return -1 ; } }2.17.1
The
sanity_testis ok now and does not have any mempool leaks.What about other tests in this file: Do you plan to work on them also?
--
Lukasz Wojciechowski
Principal Software EngineerSamsung R&D Institute Poland
Samsung Electronics
Office +48 22 377 88 25
[email protected]
Re: [dpdk-dev] [PATCH v2] app/test/test_distributor.c: prevent memory leakages from the pool
W dniu 15.04.2020 o 09:06, Sarosh Arif pisze:
Quoted 1 line
Yes, I plan to work on them when I get time.
Great, please add me to CC. I would be glad to review it.
Quoted 90 lines
On Wed, Apr 15, 2020 at 11:52 AM Lukasz Wojciechowski <[email protected] <mailto:[email protected]>> wrote:
W dniu 15.04.2020 o 08:42, Sarosh Arif pisze: > v2: > remove double freeing of mbufs > > Signed-off-by: Sarosh Arif <[email protected] <mailto:[email protected]>> > --- > app/test/test_distributor.c | 9 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/app/test/test_distributor.c b/app/test/test_distributor.c > index ba1f81cf8..5e972bb2e 100644 > --- a/app/test/test_distributor.c > +++ b/app/test/test_distributor.c > @@ -128,6 +128,7 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p) > printf("Line %d: Error, not all packets flushed. " > "Expected %u, got %u\n", > __LINE__, BURST, total_packet_count()); > + rte_mempool_put_bulk(p, (void *)bufs, BURST); > return -1; > } > > @@ -153,6 +154,7 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p) > printf("Line %d: Error, not all packets flushed. " > "Expected %u, got %u\n", > __LINE__, BURST, total_packet_count()); > + rte_mempool_put_bulk(p, (void *)bufs, BURST); > return -1; > } > > @@ -179,6 +181,7 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p) > printf("Line %d: Error, not all packets flushed. " > "Expected %u, got %u\n", > __LINE__, BURST, total_packet_count()); > + rte_mempool_put_bulk(p, (void *)bufs, BURST); > return -1; > } > > @@ -233,6 +236,7 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p) > if (num_returned != BIG_BATCH) { > printf("line %d: Missing packets, expected %d\n", > __LINE__, num_returned); > + rte_mempool_put_bulk(p, (void *)many_bufs, BIG_BATCH); > return -1; > } > > @@ -247,6 +251,7 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p) > > if (j == BIG_BATCH) { > printf("Error: could not find source packet #%u\n", i); > + rte_mempool_put_bulk(p, (void *)many_bufs, BIG_BATCH); > return -1; > } > } > > 2.17.1 > The sanity_test is ok now and does not have any mempool leaks. What about other tests in this file: Do you plan to work on them also? -- Lukasz Wojciechowski Principal Software Engineer Samsung R&D Institute Poland Samsung Electronics Office +48 22 377 88 25 [email protected] <mailto:[email protected]>
Signature · 7 lines
Lukasz Wojciechowski Principal Software Engineer Samsung R&D Institute Poland Samsung Electronics Office +48 22 377 88 25 [email protected]
A message that is not in the archive (sent off-list or not yet received): CABoZmYPV-GXESgjey7-g-j=cNif38O-SZ4L7TfrDTwb6KfDsog@mail.gmail.com
A message that is not in the archive (sent off-list or not yet received): CABoZmYOhpYqV07Q4JguvSwJmAPzfhO-f8fMKUzsMoUdUGU5hjQ@mail.gmail.com
Re: [dpdk-dev] [PATCH v2] app/test/test_distributor.c: prevent memory leakages from the pool
Some tests are failing on this patch but I don't think the reason behind the failure is this patch. Is there a certain way to know that the problem is in the patch or somewhere else?
Quoted 103 lines · Sarosh Arif
Some tests are failing on this patch but I don't think the reason behind the failure is this patch. Is there a certain way to know that the problem is in the patch or somewhere else?
Quoted 99 lines · Sarosh Arif
Sure, will do that.
Quoted 95 lines · Lukasz Wojciechowski
W dniu 15.04.2020 o 09:06, Sarosh Arif pisze:
Yes, I plan to work on them when I get time.
Great, please add me to CC. I would be glad to review it.
Quoted 64 lines · Lukasz Wojciechowski
W dniu 15.04.2020 o 08:42, Sarosh Arif pisze:
Quoted 53 lines
v2:
remove double freeing of mbufsSigned-off-by Sarosh Arif <[email protected]>--- app/test/test_distributor.c | 9 +++++++ 1 file changed, 7 insertions(+)app/test/test_distributor.c +5
-0@@ -128,6 +128,7 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p)printf ("Line %d: Error, not all packets flushed. " "Expected %u, got %u\n" , __LINE__,BURST ,total_packet_count ()); +rte_mempool_put_bulk (p, (void *)bufs,BURST );return -1 ; }@@ -153,6 +154,7 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p)printf ("Line %d: Error, not all packets flushed. " "Expected %u, got %u\n" , __LINE__,BURST ,total_packet_count ()); +rte_mempool_put_bulk (p, (void *)bufs,BURST );return -1 ; }@@ -179,6 +181,7 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p)printf ("Line %d: Error, not all packets flushed. " "Expected %u, got %u\n" , __LINE__,BURST ,total_packet_count ()); +rte_mempool_put_bulk (p, (void *)bufs,BURST );return -1 ; }@@ -233,6 +236,7 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p)if (num_returned !=BIG_BATCH ) {printf ("line %d: Missing packets, expected %d\n" , __LINE__, num_returned); +rte_mempool_put_bulk (p, (void *)many_bufs,BIG_BATCH );return -1 ; }@@ -247,6 +251,7 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p)if (j ==BIG_BATCH ) {printf ("Error: could not find source packet #%u\n" , i); +rte_mempool_put_bulk (p, (void *)many_bufs,BIG_BATCH );return -1 ; } }Quoted 2 lines
2.17.1
The
sanity_testis ok now and does not have any mempool leaks.What about other tests in this file: Do you plan to work on them also?
--
Quoted 8 lines
Lukasz Wojciechowski
Principal Software EngineerSamsung R&D Institute Poland
Samsung Electronics
Office +48 22 377 88 25
[email protected]--
Lukasz Wojciechowski
Principal Software EngineerSamsung R&D Institute Poland
Samsung Electronics
Office +48 22 377 88 25
[email protected]
Re: [dpdk-dev] [PATCH v2] app/test/test_distributor.c: prevent memory leakages from the pool
Sarosh,
I cherry picked your patch on current main branch and it works and builds without problems,
maybe try resubmitting it as v3.
Best regards
Lukasz
W dniu 24.06.2020 o 12:02, Sarosh Arif pisze:
Quoted 105 lines
Some tests are failing on this patch but I don't think the reason behind the failure is this patch. Is there a certain way to know that the problem is in the patch or somewhere else?
Quoted 99 lines · Sarosh Arif
Some tests are failing on this patch but I don't think the reason behind the failure is this patch. Is there a certain way to know that the problem is in the patch or somewhere else?
Quoted 96 lines · Sarosh Arif
Sure, will do that.
Quoted 93 lines · Lukasz Wojciechowski
W dniu 15.04.2020 o 09:06, Sarosh Arif pisze:
Yes, I plan to work on them when I get time.
Great, please add me to CC. I would be glad to review it.
Quoted 63 lines · Lukasz Wojciechowski
W dniu 15.04.2020 o 08:42, Sarosh Arif pisze:
Quoted 53 lines
v2:
remove double freeing of mbufsSigned-off-by Sarosh Arif <[email protected]>--- app/test/test_distributor.c | 9 +++++++ 1 file changed, 7 insertions(+)app/test/test_distributor.c +5
-0@@ -128,6 +128,7 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p)printf ("Line %d: Error, not all packets flushed. " "Expected %u, got %u\n" , __LINE__,BURST ,total_packet_count ()); +rte_mempool_put_bulk (p, (void *)bufs,BURST );return -1 ; }@@ -153,6 +154,7 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p)printf ("Line %d: Error, not all packets flushed. " "Expected %u, got %u\n" , __LINE__,BURST ,total_packet_count ()); +rte_mempool_put_bulk (p, (void *)bufs,BURST );return -1 ; }@@ -179,6 +181,7 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p)printf ("Line %d: Error, not all packets flushed. " "Expected %u, got %u\n" , __LINE__,BURST ,total_packet_count ()); +rte_mempool_put_bulk (p, (void *)bufs,BURST );return -1 ; }@@ -233,6 +236,7 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p)if (num_returned !=BIG_BATCH ) {printf ("line %d: Missing packets, expected %d\n" , __LINE__, num_returned); +rte_mempool_put_bulk (p, (void *)many_bufs,BIG_BATCH );return -1 ; }@@ -247,6 +251,7 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p)if (j ==BIG_BATCH ) {printf ("Error: could not find source packet #%u\n" , i); +rte_mempool_put_bulk (p, (void *)many_bufs,BIG_BATCH );return -1 ; } }Quoted 2 lines
2.17.1
The
sanity_testis ok now and does not have any mempool leaks.What about other tests in this file: Do you plan to work on them also?
--
Quoted 8 lines
Lukasz Wojciechowski
Principal Software EngineerSamsung R&D Institute Poland
Samsung Electronics
Office +48 22 377 88 25
[email protected]--
Lukasz Wojciechowski
Principal Software EngineerSamsung R&D Institute Poland
Samsung Electronics
Office +48 22 377 88 25
[email protected]
Signature · 7 lines
Lukasz Wojciechowski Principal Software Engineer Samsung R&D Institute Poland Samsung Electronics Office +48 22 377 88 25 [email protected]
PATCH v3 1/1 test_distributor: prevent memory leakages from the pool
In reply to Sarosh Arifrte_mempool_get_bulk is used to get bufs/many_bufs from the pool, but at some locations when test fails the bufs/many_bufs are not returned back to the pool.
Due to this, multiple executions of distributor_autotest gives the following error message: Error getting mbufs from pool. To resolve this issue rte_mempool_put_bulk is used whenever the test fails and returns.
---
v2:
remove double freeing of mbufs
v3:
resubmit to run the tests again
--- app/test/test_distributor.c | 5 +++++ 1 file changed, 5 insertions(+)
app/test/test_distributor.c +5 -0
@@ -128,6 +128,7 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p)printf ("Line %d: Error, not all packets flushed. " "Expected %u, got %u\n" , __LINE__,BURST ,total_packet_count ()); +rte_mempool_put_bulk (p, (void *)bufs,BURST );return -1 ; }
@@ -153,6 +154,7 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p)printf ("Line %d: Error, not all packets flushed. " "Expected %u, got %u\n" , __LINE__,BURST ,total_packet_count ()); +rte_mempool_put_bulk (p, (void *)bufs,BURST );return -1 ; }
@@ -179,6 +181,7 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p)printf ("Line %d: Error, not all packets flushed. " "Expected %u, got %u\n" , __LINE__,BURST ,total_packet_count ()); +rte_mempool_put_bulk (p, (void *)bufs,BURST );return -1 ; }
@@ -233,6 +236,7 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p)if (num_returned !=BIG_BATCH ) {printf ("line %d: Missing packets, expected %d\n" , __LINE__, num_returned); +rte_mempool_put_bulk (p, (void *)many_bufs,BIG_BATCH );return -1 ; }
@@ -247,6 +251,7 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p)if (j ==BIG_BATCH ) {printf ("Error: could not find source packet #%u\n" , i); +rte_mempool_put_bulk (p, (void *)many_bufs,BIG_BATCH );return -1 ; } }
Signature · 1 line
2.25.1
Re: [dpdk-dev] [v3 PATCH] test_distributor: prevent memory leakages from the pool
W dniu 08.09.2020 o 12:22, Sarosh Arif pisze:
Quoted 55 lines
rte_mempool_get_bulkis used to get bufs/many_bufs from the pool, but at some locations when test fails the bufs/many_bufs are not returned back to the pool.
Due to this, multiple executions ofdistributor_autotestgives the following error message: Error getting mbufs from pool. To resolve this issuerte_mempool_put_bulkis used whenever the test fails and returns.Signed-off-by Sarosh Arif <[email protected]>---
v2:
remove double freeing of mbufs
v3:
resubmit to run the tests again--- app/test/test_distributor.c | 5 +++++ 1 file changed, 5 insertions(+)app/test/test_distributor.c +4
-0@@ -128,6 +128,7 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p)printf ("Line %d: Error, not all packets flushed. " "Expected %u, got %u\n" , __LINE__,BURST ,total_packet_count ()); +rte_mempool_put_bulk (p, (void *)bufs,BURST );return -1 ; }@@ -153,6 +154,7 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p)printf ("Line %d: Error, not all packets flushed. " "Expected %u, got %u\n" , __LINE__,BURST ,total_packet_count ()); +rte_mempool_put_bulk (p, (void *)bufs,BURST );return -1 ; }@@ -179,6 +181,7 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p)printf ("Line %d: Error, not all packets flushed. " "Expected %u, got %u\n" , __LINE__,BURST ,total_packet_count ()); +rte_mempool_put_bulk (p, (void *)bufs,BURST );return -1 ; }@@ -233,6 +236,7 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p)if (num_returned !=BIG_BATCH ) {printf ("line %d: Missing packets, expected %d\n" , __LINE__, num_returned); +rte_mempool_put_bulk (p, (void *)many_bufs,BIG_BATCH );return -1 ; }
app/test/test_distributor.c sanity_test(struct worker_params *wp, struct rte_mempool *p) · line 257
Quoted 7 lines
app/test/test_distributor.c +1
-0@@ -247,6 +251,7 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p)if (j ==BIG_BATCH ) {printf ("Error: could not find source packet #%u\n" , i); +rte_mempool_put_bulk (p, (void *)many_bufs,BIG_BATCH );return -1 ; } }
Signature · 7 lines
Lukasz Wojciechowski Principal Software Engineer Samsung R&D Institute Poland Samsung Electronics Office +48 22 377 88 25 [email protected]
Re: [dpdk-dev] [v3 PATCH] test_distributor: prevent memory leakages from the pool
In reply to Sarosh ArifQuoted 10 lines · Sarosh Arif
rte_mempool_get_bulkis used to get bufs/many_bufs from the pool, but at some locations when test fails the bufs/many_bufs are not returned back to the pool.
Due to this, multiple executions ofdistributor_autotestgives the following error message: Error getting mbufs from pool. To resolve this issuerte_mempool_put_bulkis used whenever the test fails and returns.Signed-off-by Sarosh Arif <[email protected]>
It deserves a Fixes: line.
I can see a ack from Lukasz.
David, review please?
Signature · 1 line
David Marchand
Re: [dpdk-dev] [v3 PATCH] test_distributor: prevent memory leakages from the pool
Hi David,
Quoted 9 lines · David Marchand
Quoted 8 lines · Sarosh Arif
rte_mempool_get_bulkis used to get bufs/many_bufs from the pool, but at some locations when test fails the bufs/many_bufs are not returned back to the pool.
Due to this, multiple executions ofdistributor_autotestgives the following error message: Error getting mbufs from pool. To resolve this issuerte_mempool_put_bulkis used whenever the test fails and returns.
Quoted 5 lines
Quoted 1 line
Signed-off-by Sarosh Arif <[email protected]>It deserves a Fixes: line.
I can see a ack from Lukasz.
David, review please?
Done. Apoligies, I should have put you on CC:
My review comments have just been sent to the mailing list.
Rgds,
Dave.
Re: [dpdk-dev] [v3 PATCH] test_distributor: prevent memory leakages from the pool
In reply to David MarchandQuoted 11 lines · David Marchand
Quoted 9 lines · Sarosh Arif
rte_mempool_get_bulkis used to get bufs/many_bufs from the pool, but at some locations when test fails the bufs/many_bufs are not returned back to the pool.
Due to this, multiple executions ofdistributor_autotestgives the following error message: Error getting mbufs from pool. To resolve this issuerte_mempool_put_bulkis used whenever the test fails and returns.
Quoted 4 lines
Quoted 1 line
Signed-off-by Sarosh Arif <[email protected]>It deserves a Fixes: line.
Should I submit another version of this patch to add fixes?
Quoted 9 lines
I can see a ack from Lukasz.
David, review please?--
David Marchand
Re: [dpdk-dev] [v3 PATCH] test_distributor: prevent memory leakages from the pool
Quoted 6 lines · Sarosh Arif
Quoted 1 line · David Marchand
It deserves a Fixes: line.
Fixes c3eabff124e6 ("distributor: add unit tests")Should I submit another version of this patch to add fixes?
I was waiting for a review from David H. and this Fixes line lgtm. I will update when applying (with the other ut tests fixes from Lukasz), no need for a new revision.
Thanks.
Signature · 1 line
David Marchand
Re: [dpdk-dev] [v3 PATCH] test_distributor: prevent memory leakages from the pool
In reply to Sarosh ArifQuoted 8 lines · Sarosh Arif
rte_mempool_get_bulkis used to get bufs/many_bufs from the pool, but at some locations when test fails the bufs/many_bufs are not returned back to the pool.
Due to this, multiple executions ofdistributor_autotestgives the following error message: Error getting mbufs from pool. To resolve this issuerte_mempool_put_bulkis used whenever the test fails and returns.
Quoted 8 lines
Signed-off-by Sarosh Arif <[email protected]>---
v2:
remove double freeing of mbufs
v3:
resubmit to run the tests again
---
}
--snip--
Looks good to me. Even though I could not repeat the conditions to cause one of these errors, the additons make sense.
In my testing, I did add in several rte_mempool_avail_count() checks to see if there were leakages, and all the mempool counts were stable, but that was due to the fixes in the patch set from Lukasz : http://patches.dpdk.org/project/dpdk/list/?series=12442
However, if there are situations where packets are not returned from workers, this should clean them up nicely before returning.
Re: [dpdk-dev] [v3 PATCH] test_distributor: prevent memory leakages from the pool
Quoted 9 lines · David Hunt
Quoted 8 lines · Sarosh Arif
rte_mempool_get_bulkis used to get bufs/many_bufs from the pool, but at some locations when test fails the bufs/many_bufs are not returned back to the pool.
Due to this, multiple executions ofdistributor_autotestgives the following error message: Error getting mbufs from pool. To resolve this issuerte_mempool_put_bulkis used whenever the test fails and returns.
Quoted 1 line
Quoted 1 line
Signed-off-by Sarosh Arif <[email protected]>
Quoted 1 line
Reviewed-by David Hunt <[email protected]>
Applied, thanks Sarosh.
Signature · 1 line
David Marchand