Skip to content

Commit

Permalink
[PATCH] cond_resched(): fix bogus might_sleep() warning
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Ingo Molnar authored and Linus Torvalds committed Jul 8, 2005
1 parent a4014d8 commit 5bbcfd9
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions kernel/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 5bbcfd9

Please sign in to comment.