Skip to content

Commit 2a4b03f

Browse files
vingu-linaroIngo Molnar
authored andcommitted
sched/fair: Prevent unlimited runtime on throttled group
When a running task is moved on a throttled task group and there is no other task enqueued on the CPU, the task can keep running using 100% CPU whatever the allocated bandwidth for the group and although its cfs rq is throttled. Furthermore, the group entity of the cfs_rq and its parents are not enqueued but only set as curr on their respective cfs_rqs. We have the following sequence: sched_move_task -dequeue_task: dequeue task and group_entities. -put_prev_task: put task and group entities. -sched_change_group: move task to new group. -enqueue_task: enqueue only task but not group entities because cfs_rq is throttled. -set_next_task : set task and group_entities as current sched_entity of their cfs_rq. Another impact is that the root cfs_rq runnable_load_avg at root rq stays null because the group_entities are not enqueued. This situation will stay the same until an "external" event triggers a reschedule. Let trigger it immediately instead. Signed-off-by: Vincent Guittot <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Acked-by: Ben Segall <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent e938b9c commit 2a4b03f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

kernel/sched/core.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7072,8 +7072,15 @@ void sched_move_task(struct task_struct *tsk)
70727072

70737073
if (queued)
70747074
enqueue_task(rq, tsk, queue_flags);
7075-
if (running)
7075+
if (running) {
70767076
set_next_task(rq, tsk);
7077+
/*
7078+
* After changing group, the running task may have joined a
7079+
* throttled one but it's still the running task. Trigger a
7080+
* resched to make sure that task can still run.
7081+
*/
7082+
resched_curr(rq);
7083+
}
70777084

70787085
task_rq_unlock(rq, tsk, &rf);
70797086
}

0 commit comments

Comments
 (0)