DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH v2] app/testpmd: fix issue with memory leaks when quit testpmd
@ 2022-03-14  5:17 Ke Zhang
  0 siblings, 0 replies; 7+ messages in thread
From: Ke Zhang @ 2022-03-14  5:17 UTC (permalink / raw)
  To: xiaoyun.li, aman.deep.singh, yuying.zhang, dev; +Cc: Ke Zhang

when dpdk is compiled in ASan, there is a memory leaks after
quit testpmd if set mcast_addr, this patch fix this issue.

Error info as following:
ERROR: LeakSanitizer: detected memory leaksDirect leak of
       192 byte(s)
0 0x7f6a2e0aeffe in __interceptor_realloc
	(/lib/x86_64-linux-gnu/libasan.so.5+0x10dffe)
1 0x565361eb340f in mcast_addr_pool_extend
	../app/test-pmd/config.c:5162
2 0x565361eb3556 in mcast_addr_pool_append
	../app/test-pmd/config.c:5180
3 0x565361eb3aae in mcast_addr_add
	../app/test-pmd/config.c:5243

Signed-off-by: Ke Zhang <ke1x.zhang@intel.com>
---
 app/test-pmd/testpmd.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index fe2ce19f99..f7e18aee25 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -3136,6 +3136,12 @@ close_port(portid_t pid)
 			continue;
 		}
 
+		if (port->mc_addr_nb != 0) {
+			/* free the pool of multicast addresses. */
+			free(port->mc_addr_pool);
+			port->mc_addr_pool = NULL;
+		}
+
 		if (is_proc_primary()) {
 			port_flow_flush(pi);
 			port_flex_item_flush(pi);
-- 
2.25.1


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

* RE: [PATCH v2] app/testpmd: fix issue with memory leaks when quit testpmd
  2022-03-14  5:52 ` [PATCH v2] " Ke Zhang
  2022-03-14  9:10   ` David Marchand
@ 2022-03-15 10:06   ` Zhang, Yuying
  1 sibling, 0 replies; 7+ messages in thread
From: Zhang, Yuying @ 2022-03-15 10:06 UTC (permalink / raw)
  To: Zhang, Ke1X, Li, Xiaoyun, Singh, Aman Deep, dev

Hi Ke,

> -----Original Message-----
> From: Zhang, Ke1X <ke1x.zhang@intel.com>
> Sent: Monday, March 14, 2022 1:53 PM
> To: Li, Xiaoyun <xiaoyun.li@intel.com>; Singh, Aman Deep
> <aman.deep.singh@intel.com>; Zhang, Yuying <yuying.zhang@intel.com>;
> dev@dpdk.org
> Cc: Zhang, Ke1X <ke1x.zhang@intel.com>
> Subject: [PATCH v2] app/testpmd: fix issue with memory leaks when quit
> testpmd
> 
> when dpdk is compiled in ASan, there is a memory leaks after quit testpmd if
> set mcast_addr, this patch fix this issue.
> 
> Error info as following:
> ERROR: LeakSanitizer: detected memory leaksDirect leak of
>        192 byte(s)
> 0 0x7f6a2e0aeffe in __interceptor_realloc
> 	(/lib/x86_64-linux-gnu/libasan.so.5+0x10dffe)
> 1 0x565361eb340f in mcast_addr_pool_extend
> 	../app/test-pmd/config.c:5162
> 2 0x565361eb3556 in mcast_addr_pool_append
> 	../app/test-pmd/config.c:5180
> 3 0x565361eb3aae in mcast_addr_add
> 	../app/test-pmd/config.c:5243
> 
> Signed-off-by: Ke Zhang <ke1x.zhang@intel.com>
> ---
>  app/test-pmd/testpmd.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index
> fe2ce19f99..f7e18aee25 100644
> --- a/app/test-pmd/testpmd.c
> +++ b/app/test-pmd/testpmd.c
> @@ -3136,6 +3136,12 @@ close_port(portid_t pid)
>  			continue;
>  		}
> 
> +		if (port->mc_addr_nb != 0) {
> +			/* free the pool of multicast addresses. */
> +			free(port->mc_addr_pool);
> +			port->mc_addr_pool = NULL;
> +		}
> +

Is port->mc_addr_pool located in shared memory and may it be freed in primary process?
BTW,  you can write a function in config.c such as mcast_addr_pool_extend() and reference in close_port().

>  		if (is_proc_primary()) {
>  			port_flow_flush(pi);
>  			port_flex_item_flush(pi);
> --
> 2.25.1


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

* RE: [PATCH v2] app/testpmd: fix issue with memory leaks when quit testpmd
  2022-03-14  5:47 Ke Zhang
@ 2022-03-15 10:00 ` Zhang, Yuying
  0 siblings, 0 replies; 7+ messages in thread
From: Zhang, Yuying @ 2022-03-15 10:00 UTC (permalink / raw)
  To: Zhang, Ke1X, Li, Xiaoyun, Singh, Aman Deep, dev

Hi Ke,

-----Original Message-----
From: Zhang, Ke1X <ke1x.zhang@intel.com> 
Sent: 2022年3月14日 13:47
To: Li, Xiaoyun <xiaoyun.li@intel.com>; Singh, Aman Deep <aman.deep.singh@intel.com>; Zhang, Yuying <yuying.zhang@intel.com>; dev@dpdk.org
Cc: Zhang, Ke1X <ke1x.zhang@intel.com>
Subject: [PATCH v2] app/testpmd: fix issue with memory leaks when quit testpmd

when dpdk is compiled in ASan, there is a memory leaks after quit testpmd if set mcast_addr, this patch fix this issue.

Error info as following:
ERROR: LeakSanitizer: detected memory leaksDirect leak of
       192 byte(s)
0 0x7f6a2e0aeffe in __interceptor_realloc
	(/lib/x86_64-linux-gnu/libasan.so.5+0x10dffe)
1 0x565361eb340f in mcast_addr_pool_extend
	../app/test-pmd/config.c:5162
2 0x565361eb3556 in mcast_addr_pool_append
	../app/test-pmd/config.c:5180
3 0x565361eb3aae in mcast_addr_add
	../app/test-pmd/config.c:5243

Signed-off-by: Ke Zhang <ke1x.zhang@intel.com>
---
 app/test-pmd/testpmd.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index fe2ce19f99..f7e18aee25 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -3136,6 +3136,12 @@ close_port(portid_t pid)
 			continue;
 		}
 
+		if (port->mc_addr_nb != 0) {
+			/* free the pool of multicast addresses. */
+			free(port->mc_addr_pool);
+			port->mc_addr_pool = NULL;
+		}
+
Is port->mc_addr_pool located in shared memory and may it be freed in primary process?
BTW,  you can write a function in config.c such as mcast_addr_pool_extend() and reference in close_port().
 		if (is_proc_primary()) {
 			port_flow_flush(pi);
 			port_flex_item_flush(pi);
--
2.25.1


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

* Re: [PATCH v2] app/testpmd: fix issue with memory leaks when quit testpmd
  2022-03-14  5:52 ` [PATCH v2] " Ke Zhang
@ 2022-03-14  9:10   ` David Marchand
  2022-03-15 10:06   ` Zhang, Yuying
  1 sibling, 0 replies; 7+ messages in thread
From: David Marchand @ 2022-03-14  9:10 UTC (permalink / raw)
  To: Ke Zhang
  Cc: Xiaoyun Li, Singh, Aman Deep, Yuying Zhang, dev, Yigit, Ferruh,
	Thomas Monjalon

On Mon, Mar 14, 2022 at 6:59 AM Ke Zhang <ke1x.zhang@intel.com> wrote:
>
> when dpdk is compiled in ASan, there is a memory leaks after
> quit testpmd if set mcast_addr, this patch fix this issue.

The memory leak is present regardless of ASan being compiled in.
Plus, afaiu, the issue happens too when closing a port.

I'd rather rephrase like:
"""
A multicast address pool is allocated for a port when using mcast_addr
testpmd commands.

When closing a port or stopping testpmd, this pool was not freed,
resulting in a leak.
This issue has been caught using ASan.

Free this pool when closing the port.
"""

>
> Error info as following:
> ERROR: LeakSanitizer: detected memory leaksDirect leak of
>        192 byte(s)
> 0 0x7f6a2e0aeffe in __interceptor_realloc
>         (/lib/x86_64-linux-gnu/libasan.so.5+0x10dffe)
> 1 0x565361eb340f in mcast_addr_pool_extend
>         ../app/test-pmd/config.c:5162
> 2 0x565361eb3556 in mcast_addr_pool_append
>         ../app/test-pmd/config.c:5180
> 3 0x565361eb3aae in mcast_addr_add
>         ../app/test-pmd/config.c:5243
>

This patch needs a Fixes: tag.


> Signed-off-by: Ke Zhang <ke1x.zhang@intel.com>
> ---
>  app/test-pmd/testpmd.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
> index fe2ce19f99..f7e18aee25 100644
> --- a/app/test-pmd/testpmd.c
> +++ b/app/test-pmd/testpmd.c
> @@ -3136,6 +3136,12 @@ close_port(portid_t pid)
>                         continue;
>                 }
>
> +               if (port->mc_addr_nb != 0) {
> +                       /* free the pool of multicast addresses. */
> +                       free(port->mc_addr_pool);
> +                       port->mc_addr_pool = NULL;
> +               }
> +

Nit: I would introduce a helper in app/test-pmd/config.c, for example,
mcast_addr_pool_destroy.


>                 if (is_proc_primary()) {
>                         port_flow_flush(pi);
>                         port_flex_item_flush(pi);
> --
> 2.25.1
>


-- 
David Marchand


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

* [PATCH v2] app/testpmd: fix issue with memory leaks when quit testpmd
  2022-03-01  2:06 [PATCH] " Ke Zhang
@ 2022-03-14  5:52 ` Ke Zhang
  2022-03-14  9:10   ` David Marchand
  2022-03-15 10:06   ` Zhang, Yuying
  0 siblings, 2 replies; 7+ messages in thread
From: Ke Zhang @ 2022-03-14  5:52 UTC (permalink / raw)
  To: xiaoyun.li, aman.deep.singh, yuying.zhang, dev; +Cc: Ke Zhang

when dpdk is compiled in ASan, there is a memory leaks after
quit testpmd if set mcast_addr, this patch fix this issue.

Error info as following:
ERROR: LeakSanitizer: detected memory leaksDirect leak of
       192 byte(s)
0 0x7f6a2e0aeffe in __interceptor_realloc
	(/lib/x86_64-linux-gnu/libasan.so.5+0x10dffe)
1 0x565361eb340f in mcast_addr_pool_extend
	../app/test-pmd/config.c:5162
2 0x565361eb3556 in mcast_addr_pool_append
	../app/test-pmd/config.c:5180
3 0x565361eb3aae in mcast_addr_add
	../app/test-pmd/config.c:5243

Signed-off-by: Ke Zhang <ke1x.zhang@intel.com>
---
 app/test-pmd/testpmd.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index fe2ce19f99..f7e18aee25 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -3136,6 +3136,12 @@ close_port(portid_t pid)
 			continue;
 		}
 
+		if (port->mc_addr_nb != 0) {
+			/* free the pool of multicast addresses. */
+			free(port->mc_addr_pool);
+			port->mc_addr_pool = NULL;
+		}
+
 		if (is_proc_primary()) {
 			port_flow_flush(pi);
 			port_flex_item_flush(pi);
-- 
2.25.1


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

* [PATCH v2] app/testpmd: fix issue with memory leaks when quit testpmd
@ 2022-03-14  5:47 Ke Zhang
  2022-03-15 10:00 ` Zhang, Yuying
  0 siblings, 1 reply; 7+ messages in thread
From: Ke Zhang @ 2022-03-14  5:47 UTC (permalink / raw)
  To: xiaoyun.li, aman.deep.singh, yuying.zhang, dev; +Cc: Ke Zhang

when dpdk is compiled in ASan, there is a memory leaks after
quit testpmd if set mcast_addr, this patch fix this issue.

Error info as following:
ERROR: LeakSanitizer: detected memory leaksDirect leak of
       192 byte(s)
0 0x7f6a2e0aeffe in __interceptor_realloc
	(/lib/x86_64-linux-gnu/libasan.so.5+0x10dffe)
1 0x565361eb340f in mcast_addr_pool_extend
	../app/test-pmd/config.c:5162
2 0x565361eb3556 in mcast_addr_pool_append
	../app/test-pmd/config.c:5180
3 0x565361eb3aae in mcast_addr_add
	../app/test-pmd/config.c:5243

Signed-off-by: Ke Zhang <ke1x.zhang@intel.com>
---
 app/test-pmd/testpmd.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index fe2ce19f99..f7e18aee25 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -3136,6 +3136,12 @@ close_port(portid_t pid)
 			continue;
 		}
 
+		if (port->mc_addr_nb != 0) {
+			/* free the pool of multicast addresses. */
+			free(port->mc_addr_pool);
+			port->mc_addr_pool = NULL;
+		}
+
 		if (is_proc_primary()) {
 			port_flow_flush(pi);
 			port_flex_item_flush(pi);
-- 
2.25.1


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

* [PATCH v2] app/testpmd: fix issue with memory leaks when quit testpmd
@ 2022-03-14  5:34 Ke Zhang
  0 siblings, 0 replies; 7+ messages in thread
From: Ke Zhang @ 2022-03-14  5:34 UTC (permalink / raw)
  To: xiaoyun.li, aman.deep.singh, yuying.zhang, dev; +Cc: Ke Zhang

when dpdk is compiled in ASan, there is a memory leaks after
quit testpmd if set mcast_addr, this patch fix this issue.

Error info as following:
ERROR: LeakSanitizer: detected memory leaksDirect leak of
       192 byte(s)
0 0x7f6a2e0aeffe in __interceptor_realloc
	(/lib/x86_64-linux-gnu/libasan.so.5+0x10dffe)
1 0x565361eb340f in mcast_addr_pool_extend
	../app/test-pmd/config.c:5162
2 0x565361eb3556 in mcast_addr_pool_append
	../app/test-pmd/config.c:5180
3 0x565361eb3aae in mcast_addr_add
	../app/test-pmd/config.c:5243

Signed-off-by: Ke Zhang <ke1x.zhang@intel.com>
---
 app/test-pmd/testpmd.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index fe2ce19f99..f7e18aee25 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -3136,6 +3136,12 @@ close_port(portid_t pid)
 			continue;
 		}
 
+		if (port->mc_addr_nb != 0) {
+			/* free the pool of multicast addresses. */
+			free(port->mc_addr_pool);
+			port->mc_addr_pool = NULL;
+		}
+
 		if (is_proc_primary()) {
 			port_flow_flush(pi);
 			port_flex_item_flush(pi);
-- 
2.25.1


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

end of thread, other threads:[~2022-03-15 10:06 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-14  5:17 [PATCH v2] app/testpmd: fix issue with memory leaks when quit testpmd Ke Zhang
  -- strict thread matches above, loose matches on Subject: below --
2022-03-14  5:47 Ke Zhang
2022-03-15 10:00 ` Zhang, Yuying
2022-03-14  5:34 Ke Zhang
2022-03-01  2:06 [PATCH] " Ke Zhang
2022-03-14  5:52 ` [PATCH v2] " Ke Zhang
2022-03-14  9:10   ` David Marchand
2022-03-15 10:06   ` Zhang, Yuying

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