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 9F2D9A0C43; Thu, 21 Oct 2021 04:31:58 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4882240150; Thu, 21 Oct 2021 04:31:58 +0200 (CEST) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id 56FE140142 for ; Thu, 21 Oct 2021 04:31:57 +0200 (CEST) Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4HZWbD61chzbnLJ; Thu, 21 Oct 2021 10:27:20 +0800 (CST) Received: from dggema767-chm.china.huawei.com (10.1.198.209) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2308.15; Thu, 21 Oct 2021 10:31:45 +0800 Received: from [10.67.103.231] (10.67.103.231) 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.15; Thu, 21 Oct 2021 10:31:44 +0800 Message-ID: <2720a501-8bde-eefb-5704-fcfb00f3baa6@huawei.com> Date: Thu, 21 Oct 2021 10:31:44 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 To: Ferruh Yigit , CC: , , , References: <1627908397-51565-1-git-send-email-lihuisong@huawei.com> <20211015034447.26368-1-lihuisong@huawei.com> <50757f4f-2d73-9552-79ce-470cfb7da322@intel.com> From: "lihuisong (C)" In-Reply-To: <50757f4f-2d73-9552-79ce-470cfb7da322@intel.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.67.103.231] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggema767-chm.china.huawei.com (10.1.198.209) X-CFilter-Loop: Reflected Subject: Re: [dpdk-dev] [PATCH V3] ethdev: fix eth device released repeatedly 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/10/19 21:09, Ferruh Yigit 写道: > On 10/15/2021 4:44 AM, Huisong Li wrote: >> In secondary process, rte_eth_dev_close() doesn't clear eth_dev->data. >> If calling rte_dev_remove() after rte_eth_dev_close(), >> in rte_eth_dev_pci_generic_remove() function, the released eth device >> still >> can be found by its name in shared memory. As a result, the eth >> device will >> be released repeatedly. The state of the eth device is modified to >> RTE_ETH_DEV_UNUSED after rte_eth_dev_close(). So this state can be >> used to >> avoid this problem. >> > > Hi Huisong, > > Can you please add Fixes line, and stable tag if the change is requested > for backport? ok. It has been added. Please review v4. > > >> Signed-off-by: Huisong Li >> --- >> v2 -> v3: >>   * fix the commit log description and the comment inside the code. >> v1 -> v2: >>    * fix the commit log description. >> RFC -> v1: >>    * fix commit log and add a judgment for secondary process. >> --- >>   lib/ethdev/ethdev_pci.h | 10 ++++++++++ >>   1 file changed, 10 insertions(+) >> >> diff --git a/lib/ethdev/ethdev_pci.h b/lib/ethdev/ethdev_pci.h >> index 8edca82ce8..fcabae02fa 100644 >> --- a/lib/ethdev/ethdev_pci.h >> +++ b/lib/ethdev/ethdev_pci.h >> @@ -151,6 +151,16 @@ rte_eth_dev_pci_generic_remove(struct >> rte_pci_device *pci_dev, >>       if (!eth_dev) >>           return 0; >>   +    /* >> +     * In secondary process, a released eth device can be found by >> its name >> +     * in shared memory. >> +     * If the state of the eth device is RTE_ETH_DEV_UNUSED, it >> means the >> +     * eth device has been released. >> +     */ >> +    if (rte_eal_process_type() == RTE_PROC_SECONDARY && >> +        eth_dev->state == RTE_ETH_DEV_UNUSED) >> +        return 0; >> + >>       if (dev_uninit) { >>           ret = dev_uninit(eth_dev); >>           if (ret) >> > > .