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 06594A0542; Thu, 13 Feb 2020 14:36:46 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5E2F81BFE6; Thu, 13 Feb 2020 14:36:45 +0100 (CET) Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by dpdk.org (Postfix) with ESMTP id 1706A1BFE3 for ; Thu, 13 Feb 2020 14:36:44 +0100 (CET) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 93D6E2012F; Thu, 13 Feb 2020 08:36:43 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Thu, 13 Feb 2020 08:36:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s=mesmtp; bh=ONRV7C5fkr/LhlpcOIDF+n72zIEX/GY0ngGUk3uRQcA=; b=ZRspsMBx8VPR mkM00QfZ1ECa0czpSgkk6NdsUPhi8WumykN7Osb3I8DR0dx9wcAwoWuiRL2Ku/Oi 1to7rWbJUqhuMxD7IF8MAt0M/TKT175S8wcF1B33OU7f2dzFq4wqwRXysm13kTZ5 b4/u32bOANBemnbuOnNTz1rPeMX1d6E= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=ONRV7C5fkr/LhlpcOIDF+n72zIEX/GY0ngGUk3uRQ cA=; b=zfK3JsDTQ3SDstnm8LjAguvJrn4ERVZdEf3w3LgGTPgDm1aQDGPnHyLxY 8rDcyiFB1k5e2AxaudgeCdBRgpRlRMzoG6PI2oJG6s3GRh3EEb8nbfL4IqCXRsBF 3voUGkmg7wQHryclPVJT8usiVH4UnOhYdOXfylwGlDamH6aK/Eg+uoFcTI4jvZAf gjUm18Z8RnpQJ7dgHBrxiAnaWy/ibqZw0nc1EIzh9E3v9qkDbwv/TNcnx33vUNPL JB4KrjJfT0SUa4bdyEdqe6TJpsoamOooGF+l/lmicPfPlGr8r0K4rGp53gbeU4Ps Bi9z9bb9KJ2Q/RZhJWiFJ50KurUfA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedrieekgdehfecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkjghfggfgtgesthfuredttddtvdenucfhrhhomhepvfhhohhmrghs ucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenucfkph epjeejrddufeegrddvtdefrddukeegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghr rghmpehmrghilhhfrhhomhepthhhohhmrghssehmohhnjhgrlhhonhdrnhgvth X-ME-Proxy: Received: from xps.localnet (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 0840530600DC; Thu, 13 Feb 2020 08:36:41 -0500 (EST) From: Thomas Monjalon To: Matan Azrad , Bernard Iremonger , Ferruh Yigit Cc: dev@dpdk.org, Gaetan Rivet , David Marchand , Jeff Guo , Qi Zhang Date: Thu, 13 Feb 2020 14:36:41 +0100 Message-ID: <3042500.kGzlxMrEDr@xps> In-Reply-To: <1645032.4herOUoSWf@xps> References: <1573548459-6931-1-git-send-email-matan@mellanox.com> <200f3f01-fedb-b795-a733-e135957e8e99@intel.com> <1645032.4herOUoSWf@xps> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Subject: Re: [dpdk-dev] [dpdk-stable] [PATCH 2/2] app/testpmd: fix invalid port detaching 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" More details below about the plan for 20.02. 13/02/2020 13:37, Thomas Monjalon: > Hi, > > This discussion becomes confusing so I do a summary below. > I think we can do several fixes in 20.02. > > 12/02/2020 14:49, Ferruh Yigit: > > On 2/3/2020 5:10 PM, Matan Azrad wrote: > > [stripping long discussion in favor of a summary below] > > > > Even if the PMD clear the device pointer, the testpmd still may release wrong rte_device. > > > > Yes it may, although that is less likely to occur, it requires a new device hot > > added between close() and detach of the other device. > > > > Would you be agree to say there are two problems: > > > > 1) When testpmd close a port, a new attached port can re-use it over writing > > some fields, relying the data structures of the closed port is not safe. > > > > 2) PMD not cleaning ethdev->device pointer in the .remove() may cause issues in > > double detach of a port. > > > > > > For (1) I suggest fixing it in the attach path, don't re-use an eth_dev port id > > unless it is completely freed, may need to add new state for it. Does it make sense? > > Yes we could add a CLOSED state which is set on ethdev close. > When the rte_device is freed, the PMD could set attached ports as UNUSED. > But given some ethdev ports can be open and closed dynamically, > I am not sure it is a good solution to keep them in CLOSED state and ask > PMD to remember them. > > An alternative workaround could be to allocate port_id by incrementing > a saved biggest id. So the race condition would be very unlikely. > The drawbacks are having big port_id numbers and changing the id > allocation algorithm (which is not documented anyway). > > The proposals above for port_id allocation or states rework cannot be > done in 20.02. Let's discuss and work on it in a separated thread. > > > For (2) PMDs want to get hotplug support needs to fix it. > > Yes PMDs should clear rte_eth_devices[port_id].device in .remove(). I am sending a patch adding memset(eth_dev, 0, sizeof(struct rte_eth_dev)); in rte_eth_dev_release_port(). But this patch cannot be merged after 20.02-rc1. It will wait for 20.05. > We must also protect from user calling detach on a closed port > by adding a check in cmd_operate_detach_port_parsed(), > before calling detach_port_device(). I am sending a patch adding RTE_ETH_VALID_PORTID_OR_RET() in cmd_operate_detach_port_parsed(). It should fix the issue observed by Matan with double detach. It will be a double protection if keeping the check port_id_is_invalid() in detach_port_device(). > The hotplug rmv_port_callback() must be able to call detach after close. > There are three possible fixes: > - revert the port_id_is_invalid() check in detach_port_device() > - call rte_dev_remove(rte_device) directly > - call a new function with rte_device (detach_port_device() can use it) I am sending a patch implementing the third alternative as it is both keeping the detach behaviour and fixing the race condition (i.e. protect from new port re-using the port_id between close and detach). > About the function detach_port_device() itself, yes this function is > strange to say the least. It was a convenience for detaching a rte_device > from a port_id. > The cleanup of siblings with RTE_ETH_FOREACH_DEV_OF(sibling, dev), > should probably be removed. I've added it as a temporary solution > before all PMDs are properly fixed: > rte_eth_devices[sibling].device = NULL; I propose sending such patch in 20.05 in order to merge the memset above first, and have time to get agreement from all PMD maintainers. > For info, there is a function detach_device() used by the command > "device detach "