From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by dpdk.org (Postfix) with ESMTP id 9DC651BE3E for ; Wed, 4 Jul 2018 00:13:59 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id E809B21B5A; Tue, 3 Jul 2018 18:13:58 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Tue, 03 Jul 2018 18:13:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=mesmtp; bh=PTuY0Q6hFVsrk9V5jxb4ybpnC9 hBi9Y1HVHjZgvxFnY=; b=D3Yy7EuVdpCh7XvBw2j1nRf99PWSHmtivFjRd2W3gg uX3MUujnNm24b+7/dIcPO2++20xnZnHO2DoWsp2WLRUv/ysa6U6aamoRZErEDpPN SrvxH3458Pgb8FC7Dv9FQn9XfqUHLWT2g1qKfQcKmPBZ1YPznk7Uz22+y2TrBuTe w= 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-sender:x-me-sender:x-sasl-enc; s=fm3; bh=PTuY0Q 6hFVsrk9V5jxb4ybpnC9hBi9Y1HVHjZgvxFnY=; b=Q3y36nHTwpVZ3M7iwwULkI cFl2qI6APmVO9Neh+zL50ICt6BFMjiUo3nqmi9vxPpnxBLf28J4CKYD0lWaH1pSJ sd8Wv+nYpVW855gxDK6a7ImD5YDuSP3UPYq8ySxL1Pw61Ddg/JyFI50uj/WlvXi/ Z5urHMY217WcfGi3WTRQHFS5EECTIxxYPumaXw9hIh3N29qf99GCzllqdARjo5pD ZYM8w+1W1QVKSmzpeqdQirft5Qqe1NpK9dTvf4IIkY2osG4p7+30j4t+t8/Y3L4t uhGZXD4Q1poetssjEAK0FCZVKpRJQG6o0ZJVIYOm758DIPhPyIhL+MAJGDXVG5fA == X-ME-Proxy: X-ME-Sender: Received: from xps.localnet (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 924CE10273; Tue, 3 Jul 2018 18:13:57 -0400 (EDT) From: Thomas Monjalon To: "Zhang, Qi Z" Cc: dev@dpdk.org, "Burakov, Anatoly" , "Ananyev, Konstantin" , "Richardson, Bruce" , "Yigit, Ferruh" , "Shelton, Benjamin H" , "Vangati, Narender" Date: Wed, 04 Jul 2018 00:13:56 +0200 Message-ID: <1712900.Rv84bhh2vl@xps> In-Reply-To: <039ED4275CED7440929022BC67E7061153243573@SHSMSX103.ccr.corp.intel.com> References: <20180607123849.14439-1-qi.z.zhang@intel.com> <3478184.SidI6Nhsfv@xps> <039ED4275CED7440929022BC67E7061153243573@SHSMSX103.ccr.corp.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Subject: Re: [dpdk-dev] [PATCH v8 04/19] ethdev: introduce device lock 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: , X-List-Received-Date: Tue, 03 Jul 2018 22:14:00 -0000 03/07/2018 17:08, Zhang, Qi Z: > From: Thomas Monjalon [mailto:thomas@monjalon.net] > > 02/07/2018 07:44, Qi Zhang: > > > Introduce API rte_eth_dev_lock and rte_eth_dev_unlock to let > > > application lock or unlock on specific ethdev, a locked device can't > > > be detached, this help applicaiton to prevent unexpected device > > > detaching, especially in multi-process envrionment. > > > > Trying to understand: a process of an application could try to detach a port > > while another process is against this decision. > > Why an application needs to be protected against itself? > > I think we can regard this as a help function, it help application to simplified the situation when one process want to detach a device while another one is still using it. > Application can register a callback which can do to necessary clean up (like stop traffic, release memory ...) before device be detached. Yes I agree such hook can be a good idea. > > I guess it is only an application inter-process management. > > If we really want to provide such helper in DPDK, it should not be limited to > > ethdev. > > Once we move to eal layer, we will have rte_eal_dev_lock/unlock(devname, busname). > But its also better we keep rte_eth_dev_lock/unlock to make ethdev API more completed (any port be locked means underline rte_device also be locked?) > and this is same for other device family. No. Again, a port is not exactly a device. There can be several ports per device. I think the right place for this hook is in port-level API (ethdev, crypto, etc). And as we improve only ethdev currently, without any common genericity for other device classes, it is probably fine in ethdev for now. > > > (for info, see class implementation: https://patches.dpdk.org/patch/41605/) > > > > What about hardware unplug? > > Can we detach the locked ports associated to the unplugged device? > > NO, we can't. > But do you think, we need to introduce a "force detach" version, which will ignore all locks. No, I don't think so. I am just trying to show that you cannot really "lock" a port. Maybe you should just rename those functions. After all, it is just a pre-detach hook. Wait, how is it different of RTE_ETH_EVENT_DESTROY callback? Perhaps we just need to improve the handling of the DESTROY event?