From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yuanhan Liu Subject: Re: [PATCH v8 04/19] ethdev: introduce device lock Date: Wed, 04 Jul 2018 10:19:51 +0800 Message-ID: <1530670791.2539856.1429311576.7CE52942@webmail.messagingengine.com> References: <20180607123849.14439-1-qi.z.zhang@intel.com> <20180702054450.29269-1-qi.z.zhang@intel.com> <20180702054450.29269-5-qi.z.zhang@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Cc: konstantin.ananyev@intel.com, dev@dpdk.org, bruce.richardson@intel.com, ferruh.yigit@intel.com, benjamin.h.shelton@intel.com, narender.vangati@intel.com To: Qi Zhang , thomas@monjalon.net, anatoly.burakov@intel.com Return-path: Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by dpdk.org (Postfix) with ESMTP id 3DA451B598 for ; Wed, 4 Jul 2018 04:19:53 +0200 (CEST) In-Reply-To: <20180702054450.29269-5-qi.z.zhang@intel.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Mon, Jul 2, 2018, at 1:44 PM, Qi Zhang wrote: > 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. I'm just wondering why the need of introducing such 2 (very specific) APIs, judging that it looks like a ref count could solve this kind of issues perfectly. Also, the API name (_dev_lock/unlock) looks like an over killing, judging that you just want to pin a device (if I understand this commit log correctly). What firstly comes to my mind when I see "lock" was "no one can *access* a device after another has grabbed the lock", which doesn't quite match what you described here. That said, if I were you, I would go with introducing few generic refcount APIs. --yliu > > Aslo introduce the new API rte_eth_dev_lock_with_callback and > rte_eth_dev_unlock_with callback to let application to register > a callback function which will be invoked before a device is going > to be detached, the return value of the function will decide if > device will continue be detached or not, this support application > to do condition check at runtime. > > Signed-off-by: Qi Zhang > Reviewed-by: Anatoly Burakov