Skip to content

Commit 46fcc4b

Browse files
lynxeye-devPeter Zijlstra
authored andcommitted
sched/deadline: Fix stale throttling on de-/boosted tasks
When a boosted task gets throttled, what normally happens is that it's immediately enqueued again with ENQUEUE_REPLENISH, which replenishes the runtime and clears the dl_throttled flag. There is a special case however: if the throttling happened on sched-out and the task has been deboosted in the meantime, the replenish is skipped as the task will return to its normal scheduling class. This leaves the task with the dl_throttled flag set. Now if the task gets boosted up to the deadline scheduling class again while it is sleeping, it's still in the throttled state. The normal wakeup however will enqueue the task with ENQUEUE_REPLENISH not set, so we don't actually place it on the rq. Thus we end up with a task that is runnable, but not actually on the rq and neither a immediate replenishment happens, nor is the replenishment timer set up, so the task is stuck in forever-throttled limbo. Clear the dl_throttled flag before dropping back to the normal scheduling class to fix this issue. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Acked-by: Juri Lelli <juri.lelli@redhat.com> Link: https://lkml.kernel.org/r/20200831110719.2126930-1-l.stach@pengutronix.de
1 parent 8e0e0ed commit 46fcc4b

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

kernel/sched/deadline.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,12 +1527,15 @@ static void enqueue_task_dl(struct rq *rq, struct task_struct *p, int flags)
15271527
pi_se = &pi_task->dl;
15281528
} else if (!dl_prio(p->normal_prio)) {
15291529
/*
1530-
* Special case in which we have a !SCHED_DEADLINE task
1531-
* that is going to be deboosted, but exceeds its
1532-
* runtime while doing so. No point in replenishing
1533-
* it, as it's going to return back to its original
1534-
* scheduling class after this.
1530+
* Special case in which we have a !SCHED_DEADLINE task that is going
1531+
* to be deboosted, but exceeds its runtime while doing so. No point in
1532+
* replenishing it, as it's going to return back to its original
1533+
* scheduling class after this. If it has been throttled, we need to
1534+
* clear the flag, otherwise the task may wake up as throttled after
1535+
* being boosted again with no means to replenish the runtime and clear
1536+
* the throttle.
15351537
*/
1538+
p->dl.dl_throttled = 0;
15361539
BUG_ON(!p->dl.dl_boosted || flags != ENQUEUE_REPLENISH);
15371540
return;
15381541
}

0 commit comments

Comments
 (0)