Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756700Ab1FGBgi (ORCPT ); Mon, 6 Jun 2011 21:36:38 -0400 Received: from mail-qy0-f174.google.com ([209.85.216.174]:51172 "EHLO mail-qy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756218Ab1FGBgh (ORCPT ); Mon, 6 Jun 2011 21:36:37 -0400 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; b=wBtUJJ37NA/ty37HQ08+kiFBQPT1NQ/aE0NP0bZg6RfynCPvAxtIfmt4IVxdHutjzD Z2SLHfwTP3mT1XtuPf55yQRLIbCxRsRSilJ906UrmDyRzj3lD42pQ43+D9AoCLZrxlcx QltjNG+Rxw/lhYzTc6Q5bAnm7Vtzmw1w7eNi8= Date: Tue, 7 Jun 2011 03:36:32 +0200 From: Frederic Weisbecker To: "Paul E. McKenney" Cc: Milton Miller , Ingo Molnar , Peter Zijlstra , Thomas Gleixner , LKML Subject: Re: [1/4] rcu: Detect uses of rcu read side in extended quiescent states Message-ID: <20110607013630.GF17026@somewhere.redhat.com> References: <1307329858-14999-3-git-send-email-fweisbec@gmail.com> <20110606181021.GL3066@linux.vnet.ibm.com> <20110607001905.GE17026@somewhere.redhat.com> <20110607004250.GZ3066@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20110607004250.GZ3066@linux.vnet.ibm.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4357 Lines: 101 On Mon, Jun 06, 2011 at 05:42:50PM -0700, Paul E. McKenney wrote: > On Tue, Jun 07, 2011 at 02:19:07AM +0200, Frederic Weisbecker wrote: > > On Mon, Jun 06, 2011 at 11:10:21AM -0700, Paul E. McKenney wrote: > > > commit c15d76f26712bd5228aa0c6af7a7e7c492a812c9 > > > Author: Paul E. McKenney > > > Date: Tue May 24 08:31:09 2011 -0700 > > > > > > rcu: Restore checks for blocking in RCU read-side critical sections > > > > > > Long ago, using TREE_RCU with PREEMPT would result in "scheduling > > > while atomic" diagnostics if you blocked in an RCU read-side critical > > > section. However, PREEMPT now implies TREE_PREEMPT_RCU, which defeats > > > this diagnostic. This commit therefore adds a replacement diagnostic > > > based on PROVE_RCU. > > > > > > Because rcu_lockdep_assert() and lockdep_rcu_dereference() are now being > > > used for things that have nothing to do with rcu_dereference(), rename > > > lockdep_rcu_dereference() to lockdep_rcu_suspicious() and add a third > > > argument that is a string indicating what is suspicious. This third > > > argument is passed in from a new third argument to rcu_lockdep_assert(). > > > Update all calls to rcu_lockdep_assert() to add an informative third > > > argument. > > > > > > Finally, add a pair of rcu_lockdep_assert() calls from within > > > rcu_note_context_switch(), one complaining if a context switch occurs > > > in an RCU-bh read-side critical section and another complaining if a > > > context switch occurs in an RCU-sched read-side critical section. > > > These are present only if the PROVE_RCU kernel parameter is enabled. > > > > > > Again, you must enable PROVE_RCU to see these new diagnostics. But you > > > are enabling PROVE_RCU to check out new RCU uses in any case, aren't you? > > > > > > Signed-off-by: Paul E. McKenney > > > > A little comment about this patch: > > > > > > > diff --git a/kernel/rcutree.c b/kernel/rcutree.c > > > index 88547c8..8b4b3da 100644 > > > --- a/kernel/rcutree.c > > > +++ b/kernel/rcutree.c > > > @@ -153,6 +153,12 @@ void rcu_bh_qs(int cpu) > > > */ > > > void rcu_note_context_switch(int cpu) > > > { > > > + rcu_lockdep_assert(!lock_is_held(&rcu_bh_lock_map), > > > + "Illegal context switch in RCU-bh" > > > + " read-side critical section"); > > > + rcu_lockdep_assert(!lock_is_held(&rcu_sched_lock_map), > > > + "Illegal context switch in RCU-sched" > > > + " read-side critical section"); > > > > This looks like more a check to make inside might_sleep(). > > It's better because might_sleep() triggers the check even if > > we don't actually go to sleep. > > This does make quite a bit of sense. > > > In fact I believe might_sleep() already does the job fine: > > > > If !PREEMPT, might_sleep() detects that preemption is disabled > > by rcu_read_lock(). > > If !PREEMPT, isn't the preempt_disable() called by rcu_read_lock() > implemented as follows? > > #define preempt_disable() do { } while (0) > > Unless I am missing something, __might_sleep() won't detect that. Ah, right. > > If PREEMPT, might_sleep() checks rcu_preempt_depth(). > > Agreed, for CONFIG_TREE_PREEMPT_RCU and CONFIG_TINY_PREEMPT_RCU, > the existing might_sleep() checks do cover it. > > So I could export an rcu_might_sleep() or some such that contained > the above two rcu_lockdep_assert()s, but only if !PREEMPT_RCU. > If PREEMPT_RCU, rcu_might_sleep() would be a no-op. > > Seem reasonable, or am I missing something? Ok but that only improves the rcu debugging. What about instead improving might_sleep() to also work in !PREEMPT, so that it profits to any detection of forbidden sleeping (sleep inside spinlock, preempt_disable, might_fault, etc...) We could define a new config: config PREEMPT_COUNT default PREEMPT || DEBUG_SPINLOCK_SLEEP and build preempt_disable()/preempt_enable() on top of that instead of using CONFIG_PREEMPT directly. Does that look sane? -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/