From: "lihuisong (C)" <lihuisong@huawei.com>
To: Thomas Monjalon <thomas@monjalon.net>
Cc: <dev@dpdk.org>, <ferruh.yigit@intel.com>,
<aman.deep.singh@intel.com>, <andrew.rybchenko@oktetlabs.ru>,
<anatoly.burakov@intel.com>
Subject: Re: [dpdk-dev] [PATCH V2] ethdev: fix eth device released repeatedly
Date: Thu, 14 Oct 2021 20:32:20 +0800 [thread overview]
Message-ID: <13a0f09e-fc93-3256-e58f-11cec1e02dc8@huawei.com> (raw)
In-Reply-To: <2527815.Doo92MvZa3@thomas>
Hi, Thomas
*The commit log:*
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.
Is that will be more clear?
/*
* 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, which means
* the eth device has been released.
*/
Is it ok to use the above description as a comment in the code?
Hope for your reply. Thanks.
在 2021/10/12 23:33, Thomas Monjalon 写道:
> 12/10/2021 13:39, Huisong Li:
>> The rte_eth_dev_pci_generic_remove() will be called to detach an Ethernet
>> device when App calls rte_dev_remove() to detach a pci device. In addition,
>> the rte_eth_dev_close() can also detach an Ethernet device.
>> In secondary process, if App first calls rte_eth_dev_close() and then calls
>> rte_dev_remove(), because rte_eth_dev_close() doesn't clear "eth_dev->data"
> It would be clearer if you start this sentence with:
> "In secondary process, rte_eth_dev_close() doesn't clear eth_dev->data."
> Then you can explain that if calling rte_dev_remove() after rte_eth_dev_close(),
> etc...
>
>> , the address of the released Ethernet device can still be found by device
>> name. As a result, the Ethernet device will be released repeatedly in this
>> case. The state of the Ethernet device is equal to RTE_ETH_DEV_UNUSED after
>> calling rte_eth_dev_close(). Use this state to avoid this problem.
>>
>> Signed-off-by: Huisong Li<lihuisong@huawei.com>
>> ---
>> + /*
>> + * In secondary process, if applications first call rte_eth_dev_close()
>> + * and then call this interface, because rte_eth_dev_close() doesn't
>> + * clear eth_dev->data, the address of the released Ethernet device can
>> + * still be found by device name. As a result, the Ethernet device will
>> + * be released repeatedly in this case.
>> + * The state of the Ethernet device is equal to RTE_ETH_DEV_UNUSED after
>> + * calling rte_eth_dev_close(). Use this state to avoid this problem.
> This is a comment for the commit log.
> Inside the code, we should be more to the point.
> I suggest this comment:
> /* A released port can be found by its name in shared memory. */
>
>> + */
>> + if (rte_eal_process_type() != RTE_PROC_PRIMARY &&
> Better to directly compare with RTE_PROC_SECONDARY
>
>> + eth_dev->state == RTE_ETH_DEV_UNUSED) {
>> + RTE_ETHDEV_LOG(INFO, "The ethdev port has been released.");
> Not sure we need any log here.
>
>> + return 0;
>> + }
>
>
> .
next prev parent reply other threads:[~2021-10-14 12:32 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-02 12:46 [dpdk-dev] [RFC V1] ethdev: fix the issue that dev uninit may be called twice Huisong Li
2021-08-03 2:30 ` [dpdk-dev] [RFC V2] ethdev: fix issue that dev close in PMD calls twice Huisong Li
2021-08-13 2:11 ` Huisong Li
2021-08-13 6:12 ` Thomas Monjalon
2021-08-13 8:16 ` Huisong Li
2021-08-18 11:24 ` Ferruh Yigit
2021-08-19 3:45 ` Huisong Li
2021-08-24 14:42 ` Ferruh Yigit
2021-08-25 9:53 ` Huisong Li
2021-09-04 1:23 ` Huisong Li
2021-09-18 3:31 ` Huisong Li
2021-09-20 14:07 ` Ferruh Yigit
2021-09-22 3:31 ` Huisong Li
2021-09-28 7:19 ` Singh, Aman Deep
2021-09-30 10:54 ` Huisong Li
2021-09-30 11:01 ` Ferruh Yigit
2021-10-08 6:13 ` lihuisong (C)
2021-08-18 9:47 ` [dpdk-dev] [RFC V1] ethdev: fix the issue that dev uninit may be called twice Singh, Aman Deep
2021-08-24 2:10 ` Huisong Li
2021-10-08 8:21 ` [dpdk-dev] [PATCH] ethdev: fix eth device released repeatedly Huisong Li
2021-10-08 10:23 ` Thomas Monjalon
2021-10-09 1:29 ` lihuisong (C)
2021-10-12 11:39 ` [dpdk-dev] [PATCH V2] " Huisong Li
2021-10-12 15:33 ` Thomas Monjalon
2021-10-14 3:50 ` lihuisong (C)
2021-10-14 12:32 ` lihuisong (C) [this message]
2021-10-14 12:50 ` Thomas Monjalon
2021-10-15 3:03 ` lihuisong (C)
2021-10-15 3:44 ` [dpdk-dev] [PATCH V3] " Huisong Li
2021-10-19 13:09 ` Ferruh Yigit
2021-10-21 2:31 ` lihuisong (C)
2021-10-21 2:24 ` [dpdk-dev] [PATCH V4] " Huisong Li
2021-10-21 21:19 ` Ferruh Yigit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=13a0f09e-fc93-3256-e58f-11cec1e02dc8@huawei.com \
--to=lihuisong@huawei.com \
--cc=aman.deep.singh@intel.com \
--cc=anatoly.burakov@intel.com \
--cc=andrew.rybchenko@oktetlabs.ru \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@intel.com \
--cc=thomas@monjalon.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).