From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752130AbdFJOCi (ORCPT ); Sat, 10 Jun 2017 10:02:38 -0400 Received: from merlin.infradead.org ([205.233.59.134]:46356 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752038AbdFJOCh (ORCPT ); Sat, 10 Jun 2017 10:02:37 -0400 Date: Sat, 10 Jun 2017 16:02:12 +0200 From: Peter Zijlstra To: "Levin, Alexander (Sasha Levin)" Cc: Linus Torvalds , Thomas Gleixner , Ingo Molnar , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] rt_mutex: correctly initialize lockdep in rt_mutex_init_proxy_locked Message-ID: <20170610140212.GM8337@worktop.programming.kicks-ass.net> References: <20170610024705.13548-1-alexander.levin@verizon.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170610024705.13548-1-alexander.levin@verizon.com> User-Agent: Mutt/1.5.22.1 (2013-10-16) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jun 10, 2017 at 02:48:04AM +0000, Levin, Alexander (Sasha Levin) wrote: > lockdep can't deal with NULL name or key, and doesn't do anything > with the lock when that happens. Not doing anything is 'right', the proxy stuff won't be lockdep tracked anyway. But yeah, the first thing is a wee bit of a problem, for it will trigger DEBUG_LOCKS_WARN_ON() and fully kill lockdep. > Make rt_mutex_init_proxy_locked pass a name and a key for the lock. > > Fixes: f5694788ad8d ("rt_mutex: Add lockdep annotations") > Cc: Linus Torvalds > Cc: Peter Zijlstra > Cc: Thomas Gleixner > Cc: Ingo Molnar > Cc: linux-kernel@vger.kernel.org > Signed-off-by: Sasha Levin > --- > kernel/locking/rtmutex.c | 6 ++++-- > kernel/locking/rtmutex_common.h | 12 ++++++++++-- > 2 files changed, 14 insertions(+), 4 deletions(-) > > diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c > index 43123533e9b1..f540961cec30 100644 > --- a/kernel/locking/rtmutex.c > +++ b/kernel/locking/rtmutex.c > @@ -1679,10 +1679,12 @@ EXPORT_SYMBOL_GPL(__rt_mutex_init); > * possible at this point because the pi_state which contains the rtmutex > * is not yet visible to other tasks. > */ > -void rt_mutex_init_proxy_locked(struct rt_mutex *lock, > +void __rt_mutex_init_proxy_locked(struct rt_mutex *lock, > + const char *name, > + struct lock_class_key *key, > struct task_struct *proxy_owner) > { > - __rt_mutex_init(lock, NULL, NULL); > + __rt_mutex_init(lock, name, key); > debug_rt_mutex_proxy_lock(lock, proxy_owner); > rt_mutex_set_owner(lock, proxy_owner); > } Yeah, no need to do that; all we really need here is something like: --- kernel/locking/rtmutex-debug.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/locking/rtmutex-debug.c b/kernel/locking/rtmutex-debug.c index ac35e648b0e5..8dc647dc4b4b 100644 --- a/kernel/locking/rtmutex-debug.c +++ b/kernel/locking/rtmutex-debug.c @@ -175,7 +175,8 @@ void debug_rt_mutex_init(struct rt_mutex *lock, const char *name, struct lock_cl lock->name = name; #ifdef CONFIG_DEBUG_LOCK_ALLOC - lockdep_init_map(&lock->dep_map, name, key, 0); + if (name && key) + lockdep_init_map(&lock->dep_map, name, key, 0); #endif }