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 75D4A42DDF; Thu, 6 Jul 2023 03:02:24 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 571C140144; Thu, 6 Jul 2023 03:02:24 +0200 (CEST) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id 0475D400D5; Thu, 6 Jul 2023 03:02:23 +0200 (CEST) Received: from dggpeml100024.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4QxJ8J3ZGkztQxb; Thu, 6 Jul 2023 08:59:28 +0800 (CST) Received: from [10.67.100.224] (10.67.100.224) by dggpeml100024.china.huawei.com (7.185.36.115) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 6 Jul 2023 09:02:20 +0800 Subject: Re: [PATCH v1 2/2] examples/multi_process: fix memory leak To: Wenjun Wu , , , CC: , References: <20230705092511.362484-1-wenjun1.wu@intel.com> <20230705092511.362484-3-wenjun1.wu@intel.com> From: fengchengwen Message-ID: Date: Thu, 6 Jul 2023 09:02:20 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: <20230705092511.362484-3-wenjun1.wu@intel.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.100.224] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpeml100024.china.huawei.com (7.185.36.115) X-CFilter-Loop: Reflected 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 2023/7/5 17:25, Wenjun Wu wrote: > The device should be detached before quit, otherwise it will > cause memory leak. Which memory will leak? For mp, if secondary process quit, it only needs to properly handle the memory shared with other process. > > Fixes: 05f1d6842fc3 ("examples/multi_process: add hotplug sample") > Cc: stable@dpdk.org > > Signed-off-by: Wenjun Wu > --- > examples/multi_process/hotplug_mp/commands.c | 22 ++++++++++++++++++++ > 1 file changed, 22 insertions(+) > > diff --git a/examples/multi_process/hotplug_mp/commands.c b/examples/multi_process/hotplug_mp/commands.c > index 88f44e00a0..143d57eeb6 100644 > --- a/examples/multi_process/hotplug_mp/commands.c > +++ b/examples/multi_process/hotplug_mp/commands.c > @@ -52,6 +52,28 @@ static void cmd_quit_parsed(__rte_unused void *parsed_result, > struct cmdline *cl, > __rte_unused void *data) > { > + uint16_t port_id; > + char dev_name[RTE_DEV_NAME_MAX_LEN]; > + struct rte_devargs da; > + > + RTE_ETH_FOREACH_DEV(port_id) { > + rte_eth_dev_get_name_by_port(port_id, dev_name); > + memset(&da, 0, sizeof(da)); > + > + if (rte_devargs_parsef(&da, "%s", dev_name)) { > + cmdline_printf(cl, > + "cannot parse devargs for device %s\n", > + dev_name); > + } > + printf("detaching before quit...\n"); > + if (!rte_eal_hotplug_remove(rte_bus_name(da.bus), da.name)) > + cmdline_printf(cl, "detached device %s\n", > + da.name); > + else > + cmdline_printf(cl, "failed to detach device %s\n", > + da.name); > + > + } > cmdline_quit(cl); > } > >