[PATCH v9 24/33] sched/deadline: Replenish a throttled task boosted while asleep
From: Mathieu Desnoyers
Date: Fri Nov 20 2026 - 08:58:39 EST
A deadline task can be throttled as it blocks, with an rt_mutex held.
Its replenishment timer is then armed. A deadline waiter can boost the
task while it sleeps.
Commit feff2e65efd8 ("sched/deadline: Unthrottle PI boosted threads
while enqueuing") lets a boost override the throttle. enqueue_task_dl()
lifts the throttle of a boosted task, and dl_task_timer() ignores a
boosted task. This covers a task that is enqueued while boosted. But a
boost of a sleeping task does not enqueue it.
T is a SCHED_DEADLINE task that holds the rt_mutex L. W is a
SCHED_DEADLINE task with an earlier deadline:
T W T's timer
uses up its runtime, sleeps
dl_throttled = 1
start_dl_timer()
pthread_mutex_timedlock(L)
rt_mutex_setprio(T, W)
T sleeps: no enqueue
dl_task_timer()
T is boosted: returns
times out
rt_mutex_setprio(T, NULL)
wakes up
enqueue_dl_entity()
dl_throttled: waits for the timer
The timer has already fired. T would never run again, not even to die
of SIGKILL. Every later waiter on L would hang too. This was found by
reading.
Fix this by returning early in dl_task_timer() only for a boosted task
that is queued. A boosted task that sleeps then takes the existing path
for a throttled task that is not queued: it is replenished.
The refill reads the parameters of the donor, from the timer. So this
relies on two earlier patches. "sched/deadline: Do not replenish a boost
from cleared parameters" keeps the refill from looping on cleared
parameters. "rtmutex: Continue the chain walk when a waiter's deadline
donor changes" keeps the donor pointer from going stale. After a deboost in
the class, "sched/deadline: Reset the donor's runtime at a deboost in
the class" starts a period of the task's own reservation.
The Sashiko AI review of this series found this.
Fixes: feff2e65efd8 ("sched/deadline: Unthrottle PI boosted threads while enqueuing")
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx>
Cc: stable@xxxxxxxxxxxxxxx
---
kernel/sched/deadline.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index 4c55a4570a92..3627ef8751e3 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -1683,10 +1683,13 @@ static enum hrtimer_restart dl_task_timer(struct hrtimer *timer)
}
/*
- * The task might have been boosted by someone else and might be in the
- * boosting/deboosting path, its not throttled.
+ * A boost overrides the throttle. enqueue_task_dl() lifts it when the
+ * boost enqueues the task, or when the task wakes up boosted. So a
+ * queued task needs nothing here. A boost of a sleeping task does not
+ * enqueue it, and it can end before the wakeup. Nothing would lift the
+ * throttle then. So let a sleeping task reach the !queued case below.
*/
- if (is_dl_boosted(dl_se))
+ if (is_dl_boosted(dl_se) && task_on_rq_queued(p))
goto unlock;
/*
--
2.47.3