Re: [PATCH v7 12/40] sched/deadline: Replenish a throttled task boosted while asleep

From: sashiko-bot

Date: Tue Nov 17 2026 - 09:55:26 EST


Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] sched/deadline: dl_task_timer() refills sleeping boosted task
from donor
--

commit 2a5083dbbf5a615c669ceffa5d4cba59162262f3
Author: Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx>

sched/deadline: Replenish a throttled task boosted while asleep

This commit changes dl_task_timer() to return early for a boosted task only
when it is queued on the runqueue, allowing a sleeping boosted task to fall
through and be replenished when its deadline timer fires.

> diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
> index 989e7e7d3f8f1..2b5a2a43addfd 100644
> --- a/kernel/sched/deadline.c
> +++ b/kernel/sched/deadline.c
> @@ -1319,10 +1319,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;
>
> /*

[Severity: Medium]
Does letting a sleeping boosted task fall through to replenish_dl_entity()
corrupt its CBS accounting by refilling its pre-boost deficit from the
donor's reservation parameters?

A task only sets dl_throttled and arms dl_timer while unboosted, so when
dl_task_timer() fires while p is still asleep, p has never executed under
the boost and dl_se->runtime and dl_se->deadline still reflect p's own
pre-sleep reservation. However, replenish_dl_entity() reads runtime,
deadline, and period from pi_of(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;
}
...
}

Because dl_note_donor_refill() sets dl_se->dl_donor_refill, if the donor
times out and deboosts p before wakeup, dl_deboost() resets dl_se->deadline
and dl_se->runtime to a full new period, forgiving any runtime overrun p
owed before going to sleep.

If p instead wakes up while still boosted after overrunning its own budget,
the while loop above pays off p's overrun in multiples of the donor's
smaller runtime and period, which can push p's boosted deadline several
donor periods into the future. For a constrained-deadline task whose
dl_timer fires at dl_next_period(dl_se), adding a donor's shorter dl_period
to p's earlier dl_se->deadline can leave dl_se->deadline behind rq_clock(rq)
and falsely trigger the "sched: DL replenish lagged too much" warning. If
the donor left SCHED_DEADLINE and had its parameters cleared before
dl_task_timer() runs, the !runtime branch in replenish_dl_entity() skips
dl_note_donor_refill() and the deadline update because dl_se->dl_deadline is
non-zero, leaving p's expired deadline in the past after dl_deboost().
Finally, if p changed policy while sleeping and boosted, refilling from the
donor before 0-lag time leaves donor-derived runtime and deadline on p when
rt_mutex_setprio() drops the boost via dl_drop_boost().

--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1794922146.git.mathieu.desnoyers@xxxxxxxxxxxx?part=12