projects/linux·commit 5bbcfd90

[PATCH] cond_resched(): fix bogus might_sleep() warning

5bbcfd90 · Ingo Molnar <[email protected]> · 2005-07-07 17:57:04 -07:00

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 <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
Commit
5bbcfd9000887c0da7d57cc7b3ac869fc0dd5aa9
Parents
a4014d8f

Changes

1 files changed · +7 −0

FileStatusAddDelContent
kernel/sched.cmodified+7−0View file

kernel/sched.c

View file
diff --git a/kernel/sched.c b/kernel/sched.c
index 5f2182d..4107db0 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -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();