From 916304f2430e56f3e0606330a6bd1de73b4d8d6e Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Wed, 10 Jul 2019 12:57:36 +0200 Subject: [PATCH] sched/core: Fix preempt warning in ttwu John reported a DEBUG_PREEMPT warning caused by commit: aacedf26fb76 ("sched/core: Optimize try_to_wake_up() for local wakeups") I overlooked that ttwu_stat() requires preemption disabled. Reported-by: John Stultz Tested-by: John Stultz Signed-off-by: Peter Zijlstra (Intel) Cc: Andrew Morton Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Fixes: aacedf26fb76 ("sched/core: Optimize try_to_wake_up() for local wakeups") Link: https://lkml.kernel.org/r/20190710105736.GK3402@hirez.programming.kicks-ass.net Signed-off-by: Ingo Molnar Change-Id: I385c5e0796c36e35761cc4658edd3c00ac908bfb Signed-off-by: Alexander Winkowski --- kernel/sched/core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index d08ac2efa52e..34015bdec12d 100755 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -2099,6 +2099,7 @@ try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags, unsigned long flags; int cpu, success = 0; + preempt_disable(); if (p == current) { /* * We're waking current, this means 'p->on_rq' and 'task_cpu(p) @@ -2112,7 +2113,7 @@ try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags, * it disabling IRQs (this allows not taking ->pi_lock). */ if (!(p->state & state)) - return false; + goto out; success = 1; cpu = task_cpu(p); @@ -2228,6 +2229,7 @@ unlock: out: if (success) ttwu_stat(p, cpu, wake_flags); + preempt_enable(); #ifdef CONFIG_SCHED_WALT if (success && sched_predl) {