Re: [1/4] rcu: Detect uses of rcu read side in extended quiescentstates

From: Paul E. McKenney
Date: Tue Jun 07 2011 - 14:34:24 EST

On Tue, Jun 07, 2011 at 02:58:13PM +0200, Frederic Weisbecker wrote:
> On Mon, Jun 06, 2011 at 09:40:05PM -0700, Paul E. McKenney wrote:>
> > The bit I am missing is how to distinguish between spinlocks (where
> > sleeping is illegal) and mutexes (where sleeping is perfectly fine).
> > We could teach lockdep the difference, I suppose, but it is not clear
> > to me that it is worth it.
> Ah, in fact it doesn't pass through any lockdep check.
> It's only a function called might_sleep() that is placed in functions
> that can sleep. And inside might_sleep() it checks whether it is in a preemptible
> area. So it's actually locking-agnostic, it only relies on the preempt_count
> and some more for the preempt rcu cases.
> I think it is called CONFIG_DEBUG_SPINLOCK_SLEEP because it was first used
> for spinlock debugging purposes. But then it has a broader use now: sleep
> inside preemptible section, sleep inside interrupts, sleep inside rcu.

But the __might_sleep() function can only differentiate between
spinlocks and sleeplocks if CONFIG_PREEMPT=y.

> It certainly deserves a rename, like CONFIG_DEBUG_ILLEGAL_SLEEP.

Hmmm... It already checks for sleeping in the middle of a
preempt_disable() as well as in a spinlock critical section.
So the need for a rename is independent of any RCU checking.

> > In contrast, with RCU, this is straightforward -- check for rcu_sched
> > and rcu_bh, but not SRCU.

Actually it makes sense to keep the checks in rcu_note_context_switch(),
as there are places that call schedule() directly without a might_sleep().
Perhaps having checks in both places is the correct approach?

Thanx, Paul
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at