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 12E01A0548; Mon, 27 Sep 2021 03:44:31 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8B73C40686; Mon, 27 Sep 2021 03:44:30 +0200 (CEST) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id DC8374003D for ; Mon, 27 Sep 2021 03:44:28 +0200 (CEST) Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4HHllL2zLzzWVwN; Mon, 27 Sep 2021 09:43:10 +0800 (CST) Received: from dggema767-chm.china.huawei.com (10.1.198.209) by dggemv704-chm.china.huawei.com (10.3.19.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2308.8; Mon, 27 Sep 2021 09:44:26 +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; Mon, 27 Sep 2021 09:44:25 +0800 To: Thomas Monjalon CC: , , References: <20210907034108.58763-1-lihuisong@huawei.com> <2004569.RrOHqjGOaX@thomas> <430246ab-36ce-402f-8570-d305ada9d720@huawei.com> <4188639.QZEZhMFxuf@thomas> From: Huisong Li Message-ID: Date: Mon, 27 Sep 2021 09:44:18 +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: <4188639.QZEZhMFxuf@thomas> Content-Type: text/plain; charset="utf-8"; 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" 在 2021/9/27 3:16, Thomas Monjalon 写道: > 26/09/2021 14:20, Huisong Li: >> 在 2021/9/18 16:46, Thomas Monjalon 写道: >>> 18/09/2021 05:24, Huisong Li: >>>> 在 2021/9/17 20:50, Thomas Monjalon 写道: >>>>> 17/09/2021 04:13, Huisong Li: >>>>>> How should PMD free it? What should we do? Any good suggestions? >>>>> Check that there is no other port sharing the same PCI device, >>>>> then call the PMD callback for rte_pci_remove_t. >>>> For primary and secondary processes, their rte_pci_device is independent. >>> Yes it requires to free on both primary and secondary. >>> >>>> Is this for a scenario where there are multiple representor ports under >>>> the same PCI address in the same processe? >>> A PCI device can have multiple physical or representor ports. >> Got it. >>>>>> Would it be more appropriate to do this in rte_eal_cleanup() if it >>>>>> cann't be done in the API above? >>>>> rte_eal_cleanup is a last cleanup for what was not done earlier. >>>>> We could do that but first we should properly free devices when closed. >>>>> >>>> Totally, it is appropriate that rte_eal_cleanup is responsible for >>>> releasing devices under the pci bus. >>> Yes, but if a device is closed while the rest of the app keep running, >>> we should not wait to free it. >> From this point of view, it seems to make sense. However, according to >> the OVS-DPDK >> >> usage, it calls dev_close() first, and then check whether all ports >> under the PCI address are >> >> closed to free rte_pci_device by calling rte_dev_remove(). >> >> >> If we do not want the user to be aware of this, and we want >> rte_pci_device to be freed >> >> in a timely manner. Can we add a code logic calculating the number of >> ports under a PCI address >> >> and calling rte_dev_remove() to rte_eth_dev_close() to free >> rte_pci_device and delete it from rte_pci_bus? >> >> If we do, we may need to make some extra work, otherwise some >> applications, such as OVS-DPDK, will >> >> fail due to a second call to rte_dev_remove(). > I don't understand the proposal. > Please could explain again the code path? 1. This RFC patch intended to free rte_pci_device in DPDK app by calling rte_dev_remove() after calling dev_close(). 2. For the above-mentioned usage in OVS-DPDK, please see function netdev_dpdk_destruct() in lib/netdev-dpdk.c. 3. Later, you suggest that the release of rte_pci_device should be done in the dev_close() API, not in the rte_eal_init() which is not real-time. To sum up, the above proposal comes out. > It may deserve a separate mail thread. > > > .