From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 5D7BA21193786 for ; Mon, 10 Dec 2018 14:24:11 -0800 (PST) Message-ID: <00810f93b199c524378b5c963d49bd798c5d9843.camel@linux.intel.com> Subject: Re: [driver-core PATCH v8 2/9] driver core: Establish order of operations for device_add and device_del via bitflag From: Alexander Duyck Date: Mon, 10 Dec 2018 14:24:10 -0800 In-Reply-To: References: <154403054034.11544.3978949383914046587.stgit@ahduyck-desk1.jf.intel.com> <154403072403.11544.10419282512791659652.stgit@ahduyck-desk1.jf.intel.com> <15b6817fd945a1622afe673b46b028bacefad72b.camel@linux.intel.com> Mime-Version: 1.0 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" To: Dan Williams Cc: "Brown, Len" , bvanassche@acm.org, linux-nvdimm , Greg KH , Linux-pm mailing list , jiangshanlai@gmail.com, Linux Kernel Mailing List , "Luis R. Rodriguez" , Pavel Machek , zwisler@kernel.org, Tejun Heo , Andrew Morton , "Rafael J. Wysocki" List-ID: On Mon, 2018-12-10 at 13:23 -0800, Dan Williams wrote: > On Mon, Dec 10, 2018 at 1:15 PM Dan Williams wrote: > > > > On Mon, Dec 10, 2018 at 12:58 PM Alexander Duyck > > wrote: > > [..] > > > Also the context for the two functions seems to be a bit different. In > > > the case of __device_attach_driver the device_lock is already held. In > > > __driver_attach the lock on the device isn't taken until after a match > > > has been found. > > > > Yes, I was only pattern matching when looking at the context of where > > dev->dead is checked in __driver_attach() and wondering why it was > > checked outside of __device_attach_driver() > > ...and now I realize the bigger point of your concern, we need to > check dev->dead after acquiring the device_lock otherwise the race is > back. We can defer that consolidation, but the larger concern of > making it internal to __device_attach_driver() still stands. I'm still not a fan of moving it into __device_attach_driver. I would much rather pull out the dev->driver check and instead place that in __device_attach_async_helper. The __device_attach function as I said took the device_lock and had already checked dev->driver. So in the non-async path it shouldn't be possible for dev->driver to ever be set anyway. In addition __device_attach_driver is called once for each driver on a given bus, so dropping the test should reduce driver load time since it is one less test that has to be performed per driver. _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm