From: Ingo Molnar Date: Fri, 8 Jul 2005 00:57:04 +0000 (-0700) Subject: [PATCH] cond_resched(): fix bogus might_sleep() warning X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=5bbcfd9000887c0da7d57cc7b3ac869fc0dd5aa9;p=GitHub%2FLineageOS%2Fandroid_kernel_samsung_universal7580.git [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 Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/kernel/sched.c b/kernel/sched.c index 5f2182d4224..4107db0dc09 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();