Commit 5bbcfd9000887c0da7d57cc7b3ac869fc0dd5aa9

Authored by Ingo Molnar
Committed by Linus Torvalds
1 parent a4014d8f61

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

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>

Showing 1 changed file with 7 additions and 0 deletions Side-by-side Diff

... ... @@ -3877,6 +3877,13 @@
3877 3877  
3878 3878 static inline void __cond_resched(void)
3879 3879 {
  3880 + /*
  3881 + * The BKS might be reacquired before we have dropped
  3882 + * PREEMPT_ACTIVE, which could trigger a second
  3883 + * cond_resched() call.
  3884 + */
  3885 + if (unlikely(preempt_count()))
  3886 + return;
3880 3887 do {
3881 3888 add_preempt_count(PREEMPT_ACTIVE);
3882 3889 schedule();