Re: [PATCH v10 26/40] sched/deadline: Replenish a throttled task boosted while asleep
From: sashiko-bot
Date: Fri Nov 20 2026 - 16:22:34 EST
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] sched/deadline: missing dl_note_donor_refill() in
replenish_dl_entity()
- [Medium] sched/deadline: dl_task_timer() refills sleeping task from
donor parameters
--
commit c9c72591d4a367d03f9bada51027022e7fbe7e42
Author: Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx>
sched/deadline: Replenish a throttled task boosted while asleep
This commit lets dl_task_timer() replenish a throttled task that was PI
boosted while sleeping instead of returning early before clearing
dl_throttled.
> diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
> index 2912d13b60d60..9a4639ae676a4 100644
> --- a/kernel/sched/deadline.c
> +++ b/kernel/sched/deadline.c
> @@ -1705,10 +1705,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) && task_on_rq_queued(p))
> + if (is_dl_boosted(dl_se) && task_on_rq_queued(p))
> goto unlock;
[Severity: Medium]
Can replenish_dl_entity() leave dl_se->dl_donor_refill unset when a
sleeping SCHED_DEADLINE task's donor has its parameters cleared before
dl_task_timer() fires?
If the donor leaves SCHED_DEADLINE and reaches its 0-lag time before the
rt_mutex chain walk finishes deboosting the sleeping owner,
replenish_dl_entity() takes the cleared-parameter branch:
kernel/sched/deadline.c:replenish_dl_entity() {
if (unlikely(!runtime || !deadline || !period)) {
WARN_ON_ONCE(!is_dl_boosted(dl_se));
if (!dl_se->dl_deadline) {
dl_se->deadline = rq_clock(rq);
dl_se->runtime = 0;
dl_note_donor_refill(dl_se);
}
if (dl_se->runtime < 0 || dl_se->dl_yielded)
dl_se->runtime = 0;
dl_se->dl_yielded = 0;
dl_se->dl_throttled = 0;
return;
}
Because a SCHED_DEADLINE owner has dl_se->dl_deadline != 0, it skips
dl_note_donor_refill(dl_se) while zeroing runtime and clearing
dl_throttled. When dl_deboost() then runs, dl_se->dl_donor_refill is 0, so
it does not start a new period of the task's own reservation, leaving the
owner with runtime == 0 and a stale past deadline that prevents remaining
deadline waiters from re-boosting it. Calling dl_note_donor_refill(dl_se)
and updating dl_se->deadline unconditionally in the cleared-parameter branch
would ensure dl_deboost() resets the owner's reservation.
[Severity: Medium]
Does calling replenish_dl_entity() from dl_task_timer() refill a sleeping
task's pre-boost runtime debt using the donor's parameters?
A boosted task is never throttled with dl_timer armed while boosted, so a
task reaching dl_task_timer() with is_dl_boosted(dl_se) &&
!task_on_rq_queued(p) was throttled on its own reservation as it went to
sleep and has consumed no runtime while boosted. However,
replenish_dl_entity() reads runtime and period from pi_of(dl_se) and calls
dl_note_donor_refill(dl_se):
kernel/sched/deadline.c:replenish_dl_entity() {
if (dl_se->runtime <= 0)
dl_note_donor_refill(dl_se);
while (dl_se->runtime <= 0) {
dl_se->deadline += period;
dl_se->runtime += runtime;
}
If the sleeping owner overran its own large runtime and is boosted by a
waiter with a small dl_runtime, the loop pays back the owner's pre-boost
overrun in increments of the donor's runtime and period, pushing
dl_se->deadline multiple donor periods into the future so the owner runs
with a far-future deadline upon wakeup instead of the donor's urgent
deadline. Conversely, if the waiter times out before the owner wakes up,
dl_deboost() sees dl_se->dl_donor_refill set, grants a fresh full period
that erases the owner's pre-boost overrun, and cancels inactive_timer early
to drop running_bw before the true 0-lag time. In addition, with later
commit "sched/deadline: Boost an owner that cannot run on its own
reservation", dl_boost_start() saves the throttled sleeping task's
negative own_runtime and expired own_deadline with dl_boost_held = 1, and
dl_deboost() restores those unreplenished values after dl_task_timer() has
already cleared dl_throttled.
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1795207232.git.mathieu.desnoyers@xxxxxxxxxxxx?part=26