* Peter Zijlstra <a.p.zijlstra@xxxxxxxxx> wrote: > On Mon, 2009-07-20 at 04:12 -0400, Frederic Weisbecker wrote: > > > From: Frederic Weisbecker <fweisbec@xxxxxxxxx> > > Subject: [PATCH] sched: Check if the spinlock is locked in cond_resched_lock() > > > > Some uses of cond_resched_lock() might involve an > > unlocked spinlock, resulting in spurious sleep in > > atomic warnings. > > Check whether the spinlock is actually locked and > > take that into account in the might_sleep() check. > > > > Reported-by: Li Zefan <lizf@xxxxxxxxxxxxxx> > > Signed-off-by: Frederic Weisbecker <fweisbec@xxxxxxxxx> > > --- > > diff --git a/include/linux/sched.h b/include/linux/sched.h > > index cb070dc..2789658 100644 > > --- a/include/linux/sched.h > > +++ b/include/linux/sched.h > > @@ -2294,9 +2294,10 @@ extern int _cond_resched(void); > > > > extern int __cond_resched_lock(spinlock_t *lock); > > > > -#define cond_resched_lock(lock) ({ \ > > - __might_sleep(__FILE__, __LINE__, PREEMPT_OFFSET); \ > > - __cond_resched_lock(lock); \ > > +#define cond_resched_lock(lock) ({ \ > > + __might_sleep(__FILE__, __LINE__, spin_is_locked(lock) ? \ > > + PREEMPT_OFFSET : 0); \ > > + __cond_resched_lock(lock); \ > > }) > > > > extern int __cond_resched_softirq(void); > > > No, this looks utterly broken.. who is to say it doesn't get unlocked > right after that spin_is_locked() check? > > cond_resched_lock() callers must hold the lock they use it on, not doing > so is broken. > > So I would suggest something like the below instead: > > (utterly untested) FYI, i've undone the tip:sched/core bits from tip:master for now - please send a delta patch against tip:sched/core once this is fixed. Thanks, Ingo -- To unsubscribe from this list: send the line "unsubscribe linux-tip-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html