Commit d0cdb3ce authored by Steve Muckle's avatar Steve Muckle Committed by Ingo Molnar

sched/fair: Fix vruntime_normalized() for remote non-migration wakeup

When a task which previously ran on a given CPU is remotely queued to
wake up on that same CPU, there is a period where the task's state is
TASK_WAKING and its vruntime is not normalized. This is not accounted
for in vruntime_normalized() which will cause an error in the task's
vruntime if it is switched from the fair class during this time.

For example if it is boosted to RT priority via rt_mutex_setprio(),
rq->min_vruntime will not be subtracted from the task's vruntime but
it will be added again when the task returns to the fair class. The
task's vruntime will have been erroneously doubled and the effective
priority of the task will be reduced.

Note this will also lead to inflation of all vruntimes since the doubled
vruntime value will become the rq's min_vruntime when other tasks leave
the rq. This leads to repeated doubling of the vruntime and priority

Fix this by recognizing a WAKING task's vruntime as normalized only if
sched_remote_wakeup is true. This indicates a migration, in which case
the vruntime would have been normalized in migrate_task_rq_fair().

Based on a similar patch from John Dias <>.
Suggested-by: default avatarPeter Zijlstra <>
Tested-by: default avatarDietmar Eggemann <>
Signed-off-by: default avatarSteve Muckle <>
Signed-off-by: default avatarPeter Zijlstra (Intel) <>
Cc: Chris Redpath <>
Cc: John Dias <>
Cc: Linus Torvalds <>
Cc: Miguel de Dios <>
Cc: Morten Rasmussen <>
Cc: Patrick Bellasi <>
Cc: Paul Turner <>
Cc: Quentin Perret <>
Cc: Thomas Gleixner <>
Cc: Todd Kjos <>
Fixes: b5179ac7 ("sched/fair: Prepare to fix fairness problems on migration")
Link: default avatarIngo Molnar <>
parent 12b04875
......@@ -9644,7 +9644,8 @@ static inline bool vruntime_normalized(struct task_struct *p)
* - A task which has been woken up by try_to_wake_up() and
* waiting for actually being woken up by sched_ttwu_pending().
if (!se->sum_exec_runtime || p->state == TASK_WAKING)
if (!se->sum_exec_runtime ||
(p->state == TASK_WAKING && p->sched_remote_wakeup))
return true;
return false;
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment