From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 455B4A00BE; Mon, 14 Mar 2022 10:10:43 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CAB5140DF4; Mon, 14 Mar 2022 10:10:42 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id E02D340DDD for ; Mon, 14 Mar 2022 10:10:40 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647249040; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Ow3lADgSFCZodWb3qZ70nbWQ1u+SAtYhBlayTMcXSBY=; b=BwFmt4KBgcpYd/8gNW7cGVBOMET1SsxiJzzEXiUnerVdQDlzTdedRdmgoWpDp/qGXucFtS oQ9VG2PJLt+1w+HFgFivA1Kw4P55X/g+wrR6w3OTdGkRu+Y6tLSY17dljzhFBJua2sv93/ ydz/tdqUIqa04B4hFUF1g0PPkc/V2oA= Received: from mail-lf1-f69.google.com (mail-lf1-f69.google.com [209.85.167.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-241-VodhHuqVNYeEPYBrUno8mg-1; Mon, 14 Mar 2022 05:10:39 -0400 X-MC-Unique: VodhHuqVNYeEPYBrUno8mg-1 Received: by mail-lf1-f69.google.com with SMTP id f27-20020ac251bb000000b004486c507f80so2609942lfk.10 for ; Mon, 14 Mar 2022 02:10:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Ow3lADgSFCZodWb3qZ70nbWQ1u+SAtYhBlayTMcXSBY=; b=ahu+pQVKPZdAq3ghqELG3/bM3K3+JF47L3jzGD+/OVDPUeYs42RWmejoE9FRdY6Zsr HgUCXpWZsrGrLhSUhdcgc5jssWDLf+8wwAEhh4h/i/N9gk4Qh0S0xsPNhW0TLvjmKqyJ ny7azgjyIuBkEVDi3nuD7ufx1SR4fSwekJCIHDHlWZJQBU1owYeV+Q1eQuRW3LH0dXti lyM2WmQg3b7LSgzNy3yzF5/cwtZlPYNncHEMQmNhUmDbB06N3GPoe0hqf+P/f5wBjV4p 8hHzWRR7b7Z/5hnLb0/obLtff3p+92dv81L/3CpMD7nTPDxeXL6FMkqtlIlWSnuPzWSQ OGMg== X-Gm-Message-State: AOAM530WWgVjoTjjtSVsO/zKtzN+eeNTSjrMolhyISOaNrhbIwJFyUkc Ifx4d0Dbscr5onjYwVE8uyahjj85lvu3hRkdqzc3hr0Jab+gLtxsTquvvTlVXR1xpLtrALLbvME CbiytXWmWpFbVyVUmqsw= X-Received: by 2002:a05:6512:39ce:b0:448:36de:d2ea with SMTP id k14-20020a05651239ce00b0044836ded2eamr13244461lfu.499.1647249037446; Mon, 14 Mar 2022 02:10:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyqY6Sov8a8q4N/BE2NurYh6u1ND2RQgYtQ0AMsRju9ujz2EG/gSSn8yp3pbLcbhkOX+rMrdTFtLcZp6N66Ifk= X-Received: by 2002:a05:6512:39ce:b0:448:36de:d2ea with SMTP id k14-20020a05651239ce00b0044836ded2eamr13244445lfu.499.1647249037087; Mon, 14 Mar 2022 02:10:37 -0700 (PDT) MIME-Version: 1.0 References: <20220301020653.329263-1-ke1x.zhang@intel.com> <20220314055252.392004-1-ke1x.zhang@intel.com> In-Reply-To: <20220314055252.392004-1-ke1x.zhang@intel.com> From: David Marchand Date: Mon, 14 Mar 2022 10:10:25 +0100 Message-ID: Subject: Re: [PATCH v2] app/testpmd: fix issue with memory leaks when quit testpmd To: Ke Zhang Cc: Xiaoyun Li , "Singh, Aman Deep" , Yuying Zhang , dev , "Yigit, Ferruh" , Thomas Monjalon Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dmarchan@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Mon, Mar 14, 2022 at 6:59 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. 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 > --- > 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