From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Monjalon Subject: Re: [PATCH] bus/vdev: reduce scope of device list lock Date: Tue, 22 May 2018 11:20:10 +0200 Message-ID: <2833093.uzJjkH71XI@xps> References: <20180521161156.25724-1-thomas@monjalon.net> <8f0eb83d-5090-c7c8-5c3d-c4eecb96e596@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7Bit Cc: dev@dpdk.org, matan@mellanox.com, ferruh.yigit@intel.com To: "Burakov, Anatoly" Return-path: Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by dpdk.org (Postfix) with ESMTP id E1A1711D4 for ; Tue, 22 May 2018 11:20:12 +0200 (CEST) In-Reply-To: <8f0eb83d-5090-c7c8-5c3d-c4eecb96e596@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" 22/05/2018 11:05, Burakov, Anatoly: > On 21-May-18 5:11 PM, Thomas Monjalon wrote: > > The lock vdev_device_list_lock was taken before calling > > "remove" function for the device. > > So it prevents to remove sub-devices (as in failsafe) inside > > its own "remove" function, because of a deadlock. > > > > The lock is now only protecting the device list inside > > the bus driver. > > > > Fixes: 35f462839b69 ("bus/vdev: add lock on device list") > > > > Signed-off-by: Thomas Monjalon > > Without that lock, all of this would be racy - find_dev would iterate a > tailq that might change under its feet, and tailq_remove may be called > with a pointer that has already been removed. > > How about changing the lock to a recursive lock? Failsafe would be > removing devices from within the same thread, correct? Yes it could work. I will give it a try.