History

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 penalty. 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 <joaodias@google.com>.

Steve Muckle committed 8 years ago

Commit d0cdb3c1 parent 12b04871 file · +2 −1Browse files

Showing the changes to kernel (1 of 1 file). Show all

Unified · Split

kernel/sched/fair.c+2−1
@@ -9644,7 +9644,8 @@ static inline bool vruntime_normalized(struct task_struct *p) · 9643 unmodified lines
96449644 * - A task which has been woken up by try_to_wake_up() and
96459645 * waiting for actually being woken up by sched_ttwu_pending().
96469646 */
9647− if (!se->sum_exec_runtime || p->state == TASK_WAKING)
9647+ if (!se->sum_exec_runtime ||
9648+ (p->state == TASK_WAKING && p->sched_remote_wakeup))
96489649 return true;
96499650
96509651 return false;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t