Skip to content

Commit e3d8548

Browse files
Peter ZijlstraIngo Molnar
authored andcommitted
sched/core: Fix preempt warning in ttwu
John reported a DEBUG_PREEMPT warning caused by commit: aacedf2 ("sched/core: Optimize try_to_wake_up() for local wakeups") I overlooked that ttwu_stat() requires preemption disabled. Reported-by: John Stultz <[email protected]> Tested-by: John Stultz <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Fixes: aacedf2 ("sched/core: Optimize try_to_wake_up() for local wakeups") Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent f632a81 commit e3d8548

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

kernel/sched/core.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2399,6 +2399,7 @@ try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags)
23992399
unsigned long flags;
24002400
int cpu, success = 0;
24012401

2402+
preempt_disable();
24022403
if (p == current) {
24032404
/*
24042405
* We're waking current, this means 'p->on_rq' and 'task_cpu(p)
@@ -2412,7 +2413,7 @@ try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags)
24122413
* it disabling IRQs (this allows not taking ->pi_lock).
24132414
*/
24142415
if (!(p->state & state))
2415-
return false;
2416+
goto out;
24162417

24172418
success = 1;
24182419
cpu = task_cpu(p);
@@ -2526,6 +2527,7 @@ try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags)
25262527
out:
25272528
if (success)
25282529
ttwu_stat(p, cpu, wake_flags);
2530+
preempt_enable();
25292531

25302532
return success;
25312533
}

0 commit comments

Comments
 (0)