From: Ingo Molnar <mingo@elte.hu>

The BKS might be reacquired before we have dropped PREEMPT_ACTIVE, which
could trigger a second could trigger a second cond_resched() call.  Bug
found by Hirofumi Ogawa.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 kernel/sched.c |    7 +++++++
 1 files changed, 7 insertions(+)

diff -puN kernel/sched.c~cond_resched-fix-bogus-might_sleep-warning kernel/sched.c
--- 25/kernel/sched.c~cond_resched-fix-bogus-might_sleep-warning	Wed Jul  6 13:46:38 2005
+++ 25-akpm/kernel/sched.c	Wed Jul  6 13:46:38 2005
@@ -3877,6 +3877,13 @@ asmlinkage long sys_sched_yield(void)
 
 static inline void __cond_resched(void)
 {
+	/*
+	 * The BKS might be reacquired before we have dropped
+	 * PREEMPT_ACTIVE, which could trigger a second
+	 * cond_resched() call.
+	 */
+	if (unlikely(preempt_count()))
+		return;
 	do {
 		add_preempt_count(PREEMPT_ACTIVE);
 		schedule();
_