From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Collins Subject: Re: Deadlock scenario in regulator core Date: Tue, 22 Mar 2011 16:41:28 -0700 Message-ID: <4D8933A8.8080607@codeaurora.org> References: <4D891C59.1030009@codeaurora.org> <20110322223702.GO14675@home.goodmis.org> <4D892C0A.1090606@codeaurora.org> <1300835998.14261.13.camel@gandalf.stny.rr.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Return-path: Received: from wolverine01.qualcomm.com ([199.106.114.254]:21693 "EHLO wolverine01.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753531Ab1CVXl3 (ORCPT ); Tue, 22 Mar 2011 19:41:29 -0400 In-Reply-To: <1300835998.14261.13.camel@gandalf.stny.rr.com> Sender: linux-arm-msm-owner@vger.kernel.org List-Id: linux-arm-msm@vger.kernel.org To: Steven Rostedt Cc: Liam Girdwood , Mark Brown , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Peter Zijlstra , Ingo Molnar On 03/22/2011 04:19 PM, Steven Rostedt wrote: > > Looks to me that the mutex_lock() in _notifier_call_chain needs to be a > mutex_lock_nested(). > > The "_nested()" versions are when you have the same type of mutex taken > but belonging to two different instances. Like you have here: > > blocking_notifier_call_chain(&rdev->notifier, event, NULL); > > /* now notify regulator we supply */ > list_for_each_entry(_rdev, &rdev->supply_list, slist) { > mutex_lock(&_rdev->mutex); > _notifier_call_chain(_rdev, event, data); > mutex_unlock(&_rdev->mutex); > } > > The rdev->mutex is already held, so we don't need to take it to call the > blocking_notifier_call_chain() with the rdev->notifier. But then the > list of rdev's in the rdev->supply_list are different instances but we > are still taking the same type of lock. lockdep treats all instances of > the same lock the same, so to lockdep this looks like a deadlock. To > teach lockdep that this is a different instance, simply use > mutex_lock_nested() instead. > > -- Steve > > There seem to be very few uses of mutex_lock_nested() in the kernel. Most of them use subclass = SINGLE_DEPTH_NESTING. Would this be sufficient for usage in the regulator core in _notifier_call_chain (and perhaps other places) or should some other subclass be used? Thanks, David -- Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.