From patchwork Wed Apr 14 01:49:30 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 50089 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id C0DB6B7D0D for ; Wed, 14 Apr 2010 11:49:35 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754495Ab0DNBte (ORCPT ); Tue, 13 Apr 2010 21:49:34 -0400 Received: from e7.ny.us.ibm.com ([32.97.182.137]:34880 "EHLO e7.ny.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754367Ab0DNBtd (ORCPT ); Tue, 13 Apr 2010 21:49:33 -0400 Received: from d01relay03.pok.ibm.com (d01relay03.pok.ibm.com [9.56.227.235]) by e7.ny.us.ibm.com (8.14.3/8.13.1) with ESMTP id o3E1eBT6024719; Tue, 13 Apr 2010 21:40:11 -0400 Received: from d01av04.pok.ibm.com (d01av04.pok.ibm.com [9.56.224.64]) by d01relay03.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o3E1nVvt127514; Tue, 13 Apr 2010 21:49:31 -0400 Received: from d01av04.pok.ibm.com (loopback [127.0.0.1]) by d01av04.pok.ibm.com (8.14.3/8.13.1/NCO v10.0 AVout) with ESMTP id o3E1nVNS021013; Tue, 13 Apr 2010 21:49:31 -0400 Received: from paulmck-laptop.localdomain (paulmck-laptop-009047022149.beaverton.ibm.com [9.47.22.149]) by d01av04.pok.ibm.com (8.14.3/8.13.1/NCO v10.0 AVin) with ESMTP id o3E1nU5I020999; Tue, 13 Apr 2010 21:49:30 -0400 Received: by paulmck-laptop.localdomain (Postfix, from userid 1000) id 41F69181751; Tue, 13 Apr 2010 18:49:30 -0700 (PDT) Date: Tue, 13 Apr 2010 18:49:30 -0700 From: "Paul E. McKenney" To: David Miller Cc: fweisbec@gmail.com, a.p.zijlstra@chello.nl, mingo@elte.hu, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: Weird rcu lockdep warning Message-ID: <20100414014930.GI2538@linux.vnet.ibm.com> Reply-To: paulmck@linux.vnet.ibm.com References: <20100413200432.GB5099@nowhere> <20100413234043.GG2538@linux.vnet.ibm.com> <20100414000226.GH5602@nowhere> <20100413.171306.25868761.davem@davemloft.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20100413.171306.25868761.davem@davemloft.net> User-Agent: Mutt/1.5.20 (2009-06-14) Sender: sparclinux-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: sparclinux@vger.kernel.org On Tue, Apr 13, 2010 at 05:13:06PM -0700, David Miller wrote: > From: Frederic Weisbecker > Date: Wed, 14 Apr 2010 02:02:27 +0200 > > > I just have a guess though.... > > This seems to always happen from NMI path, and lockdep is disabled on NMI. > > I suspect the lock_acquire() performed by rcu_read_lock() is just ignored > > and then the rcu_read_lock_held() check has the wrong result... > > Yeah, I bet that's it too. > > lock_is_held() can't return anything meaningful while lockdep is > disabled, which it is during NMIs. Ah! So I just need to add a "current->lockdep_recursion" check to debug_lockdep_rcu_enabled(). And move the function to kernel/rcutree_plugin.h to avoid #include hell. See below for (untested) patch. Thanx, Paul ------------------------------------------------------------------------ include/linux/rcupdate.h | 5 +---- kernel/rcutree_plugin.h | 11 +++++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) commit 304d8da6cd791a81ce3164f867e1b3ef4f9af1d1 Author: Paul E. McKenney Date: Tue Apr 13 18:45:51 2010 -0700 rcu: Make RCU lockdep check the lockdep_recursion variable The lockdep facility temporarily disables lockdep checking by incrementing the current->lockdep_recursion variable. Such disabling happens in NMIs and in other situations where lockdep might expect to recurse on itself. This patch therefore checks current->lockdep_recursion, disabling RCU lockdep splats when this variable is non-zero. Reported-by: Frederic Weisbecker Reported-by: David Miller Signed-off-by: Paul E. McKenney --- To unsubscribe from this list: send the line "unsubscribe sparclinux" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h index 9f1ddfe..07db2fe 100644 --- a/include/linux/rcupdate.h +++ b/include/linux/rcupdate.h @@ -101,10 +101,7 @@ extern struct lockdep_map rcu_sched_lock_map; # define rcu_read_release_sched() \ lock_release(&rcu_sched_lock_map, 1, _THIS_IP_) -static inline int debug_lockdep_rcu_enabled(void) -{ - return likely(rcu_scheduler_active && debug_locks); -} +extern int debug_lockdep_rcu_enabled(void); /** * rcu_read_lock_held - might we be in RCU read-side critical section? diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h index 79b53bd..2169abe 100644 --- a/kernel/rcutree_plugin.h +++ b/kernel/rcutree_plugin.h @@ -1067,3 +1067,14 @@ static void rcu_needs_cpu_flush(void) } #endif /* #else #if !defined(CONFIG_RCU_FAST_NO_HZ) */ + +#ifdef CONFIG_DEBUG_LOCK_ALLOC + +int debug_lockdep_rcu_enabled(void) +{ + return likely(rcu_scheduler_active && + debug_locks && + current->lockdep_recursion == 0); +} + +#endif /* #ifdef CONFIG_DEBUG_LOCK_ALLOC */