From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 10093A04BC; Fri, 9 Oct 2020 18:10:09 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E5C241C2B7; Fri, 9 Oct 2020 18:10:07 +0200 (CEST) Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by dpdk.org (Postfix) with ESMTP id DBBA21C1FC for ; Fri, 9 Oct 2020 18:10:05 +0200 (CEST) X-Originating-IP: 86.254.165.59 Received: from u256.net (lfbn-poi-1-843-59.w86-254.abo.wanadoo.fr [86.254.165.59]) (Authenticated sender: grive@u256.net) by relay8-d.mail.gandi.net (Postfix) with ESMTPSA id A6E381BF208; Fri, 9 Oct 2020 16:10:04 +0000 (UTC) Date: Fri, 9 Oct 2020 18:09:59 +0200 From: =?utf-8?Q?Ga=C3=ABtan?= Rivet To: "Niu, Yawei" Cc: "dev@dpdk.org" , spdk@lists.01.org, "Harris, James R" , "Vanda, Sydney M" Message-ID: <20201009160959.dmqhwtqktbyagxbk@u256.net> References: <748FDEF7-6BB0-4D27-B630-4C991D06B6F8@intel.com> <98D9624D-F475-425B-9B06-F13CD9C4884C@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <98D9624D-F475-425B-9B06-F13CD9C4884C@intel.com> Subject: Re: [dpdk-dev] FW: [SPDK] Re: Potential defect in pci_unplug() X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" Hello, On 29/09/20 01:15 +0000, Niu, Yawei wrote: > > > On 2020/9/28, 11:44 PM, "Harris, James R" wrote: > > Hi Niu, > > I agree, this doesn't look right. Could you file an SPDK issue for this to make sure we track it? And then try sending an e-mail to the DPDK mailing list? I'm open to submitting a patch to our DPDK submodule short-term, but only if we get agreement with DPDK community that this fix is correct. > > Thanks, > > Jim > > > On 9/28/20, 12:17 AM, "Niu, Yawei" wrote: > > Hi, > > In the pci_unplug() (dpdk/drivers/bus/pci/pci_common.c), why do we call rte_devargs_remove() to remove the saved device args? That looks a defect to me, since that’ll result in the hot removed device failed to be detected when it’s plugged back (when white list option was provided), the situation is described following: > > 1. App starts with white list option provided, let’s suppose the device in white list is: 0000:81:00.0; > 2. rte_devargs_add() is called to add this device arg on rte_eal_init(); > 3. Issue “echo 1 > /sys/bus/pci/devices/0000\:81\:00.0/remove” to hot remove the device; > 4. pci_unplug() is called to remove the device, and rte_devargs_remove() is called, so this device arg for white list is remove too; > 5. Issue “echo 1 > /sys/bus/pci/rescan” then “PCI_WHITELIST=”0000:81:00.0” spdk/script/setup.sh” to do hot plug; > 6. In pci_scan_one(), new dev is generated, however, the dev->device.devargs is set NULL since the device args has been removed on device unplug; > 7. rte_pci_probe() does white list scan, however, it unexpectedly skips the device because the devargs of the device is NULL now; > > I don’t fully understand the DPDK code, but this rte_devargs_remove() in pci_unplug() doesn’t make sense to me (when I commented it out, seems everything will work as expected). Is this a glitch or I missed anything? This is not a glitch, the behavior is intended. When a device is unplugged from the system, there is no expectation that it will reappear at the same PCI address. When an application receives the RMV event for the device, it is alerted that the device was removed. It is its responsibility then to detect when a device it wants to use is added back. It can do so via udev on linux for example, but it is tightly coupled with the operating system or even the distribution. BSD and windows won't work that way. This is the reason this responsibility was left to the application. The failsafe PMD attempts to offer transparent hotplug capability to existing applications. It had to deal with this exact issue. The solution used there has been to use either: * the exec() sub-device type, that takes a shell command as parameter, which should return a valid device after successful execution. Intention is for the user to declare a script that will detect device hotplug on the system using other matches than PCI address (as it is unreliable), such as MAC address. * the fd() sub-device type, which is a pipe where another piece of code will send device ID into. This is what vdev_netvsc does currently: it detects on its own valid NetVSC devices and when one is suitable, it sends its PCI id in this pipe to failsafe driver. See https://doc.dpdk.org/guides/nics/fail_safe.html section 55.3.1. Fail-safe command line parameters for documentation. When a new device is hotplugged into DPDK, it is described by an rte_devargs. This new devargs is the one that will be used for identification during scan and probe. As it replaces the old, the old one needs to be removed as it is stale. Regards, -- Gaëtan