DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ferruh Yigit <ferruh.yigit@intel.com>
To: Ke Zhang <ke1x.zhang@intel.com>, <xiaoyun.li@intel.com>,
	<aman.deep.singh@intel.com>, <yuying.zhang@intel.com>,
	<dev@dpdk.org>
Subject: Re: [PATCH] app/testpmd: fix issue with memory leaks when quit testpmd
Date: Fri, 4 Mar 2022 16:43:56 +0000	[thread overview]
Message-ID: <4a963f00-c673-4361-16a1-2964ad828dc5@intel.com> (raw)
In-Reply-To: <20220301020653.329263-1-ke1x.zhang@intel.com>

On 3/1/2022 2:06 AM, Ke Zhang wrote:
> 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 | 12 ++++++++++++
>   1 file changed, 12 insertions(+)
> 
> diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
> index fe2ce19f99..fa7f80fdf7 100644
> --- a/app/test-pmd/testpmd.c
> +++ b/app/test-pmd/testpmd.c
> @@ -2742,6 +2742,8 @@ start_port(portid_t pid)
>   			continue;
>   		}
>   
> +		port->mc_addr_pool = NULL;
> +

User can do consecutive start / stop / start / ..

Won't user expect the previous allocated and set MAC address
to be valid after this?

What about to free the 'port->mc_addr_pool' in close()
instead of stop()?

>   		if (port->need_reconfig > 0) {
>   			struct rte_eth_conf dev_conf;
>   			int k;
> @@ -3065,6 +3067,16 @@ stop_port(portid_t pid)
>   		if (eth_dev_stop_mp(pi) != 0)
>   			RTE_LOG(ERR, EAL, "rte_eth_dev_stop failed for port %u\n",
>   				pi);
> +		/*
> +		 * free the pool of multicast addresses. If it is NULL,
> +		 * it means there is no mc addr.Make sure the mc_addr_pool
> +		 * is NULL at port init.
> +		 */
> +		if (port->mc_addr_pool != NULL) {
> +			free(port->mc_addr_pool);
> +			port->mc_addr_pool = NULL;
> +		}
> +		port->mc_addr_nb = 0;

will it work to use 'port->mc_addr_nb' to detect if the
'port->mc_addr_pool' pointer is valid

if (port->mc_addr_nb) {
   free(port->mc_addr_pool);
   port->mc_addr_pool = NULL;
   port->mc_addr_nb = 0;
}

>   
>   		if (port->port_status == RTE_PORT_HANDLING)
>   			port->port_status = RTE_PORT_STOPPED;


  reply	other threads:[~2022-03-04 16:44 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-01  2:06 Ke Zhang
2022-03-04 16:43 ` Ferruh Yigit [this message]
2022-03-08  6:05   ` Zhang, Ke1X
2022-03-14  5:52 ` [PATCH v2] " Ke Zhang
2022-03-14  9:10   ` David Marchand
2022-03-15 10:06   ` Zhang, Yuying
2022-03-25  8:35   ` [PATCH v3] " Ke Zhang
2022-04-04 15:34     ` Zhang, Yuying
2022-06-08 12:06       ` Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4a963f00-c673-4361-16a1-2964ad828dc5@intel.com \
    --to=ferruh.yigit@intel.com \
    --cc=aman.deep.singh@intel.com \
    --cc=dev@dpdk.org \
    --cc=ke1x.zhang@intel.com \
    --cc=xiaoyun.li@intel.com \
    --cc=yuying.zhang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).