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 C1AFDA0C56; Wed, 8 Sep 2021 04:01:46 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 59BBC410EF; Wed, 8 Sep 2021 04:01:46 +0200 (CEST) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id 3B9A9410EB for ; Wed, 8 Sep 2021 04:01:44 +0200 (CEST) Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4H44ys2NzLzYkHl; Wed, 8 Sep 2021 09:57:41 +0800 (CST) Received: from dggema767-chm.china.huawei.com (10.1.198.209) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2308.8; Wed, 8 Sep 2021 10:01:41 +0800 Received: from [10.66.74.184] (10.66.74.184) by dggema767-chm.china.huawei.com (10.1.198.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.8; Wed, 8 Sep 2021 10:01:41 +0800 To: Thomas Monjalon CC: , , References: <20210907034108.58763-1-lihuisong@huawei.com> <2757246.qzpMWD9H8a@thomas> From: Huisong Li Message-ID: <76ee3238-5d1f-70c5-3ec1-92662dea2185@huawei.com> Date: Wed, 8 Sep 2021 10:01:41 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 In-Reply-To: <2757246.qzpMWD9H8a@thomas> Content-Type: text/plain; charset="gbk"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.66.74.184] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggema767-chm.china.huawei.com (10.1.198.209) X-CFilter-Loop: Reflected Subject: Re: [dpdk-dev] [RFC V1] examples/l3fwd-power: fix memory leak for rte_pci_device 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 Sender: "dev" Hi, Thomas ÔÚ 2021/9/7 16:53, Thomas Monjalon дµÀ: > 07/09/2021 05:41, Huisong Li: >> Calling rte_eth_dev_close() will release resources of eth device and close >> it. But rte_pci_device struct isn't released when app exit, which will lead >> to memory leak. > That's a PMD issue. > When the last port of a PCI device is closed, the device should be freed. Why is this a PMD problem? I don't understand. As far as I know, most apps or examples in the DPDK project have only one port for a pci device. When the port is closed, the rte_pci_device should be freed. But none of the apps seem to do this. > >> + /* Retrieve device address in eth device before closing it. */ >> + eth_dev = &rte_eth_devices[portid]; > You should not access this array, considered internal. We have to save the address of rte_device to free rte_pci_device before closing eth device. Because the the device address in rte_eth_dev struct will be set to a NULL after closing eth device. It's also handled in OVS in this way. > >> + rte_dev = eth_dev->device; >> rte_eth_dev_close(portid); >> + ret = rte_dev_remove(rte_dev); > > > .