Re: [PATCH v8 23/33] sched/deadline: Reset the donor's runtime at a deboost in the class

From: sashiko-bot

Date: Thu Nov 19 2026 - 15:53:24 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_entity_preempt() precedes dl_deboost() in
rt_mutex_setprio()
--

commit 99ad044e86f7c0f67e987d30b947babfc918e9b4
Author: Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx>

sched/deadline: Reset the donor's runtime at a deboost in the class

This commit tracks whether a boosted deadline entity had its runtime
refilled from its donor's reservation via a new dl_donor_refill flag, and
starts a new period from the task's own parameters when the boost ends in
SCHED_DEADLINE.

> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index fe2919be3775b..781eff6455250 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -7957,16 +7957,26 @@ void rt_mutex_setprio(struct task_struct *p, struct task_struct *pi_task)
> p->dl.pi_se = pi_task->dl.pi_se;
> scope->flags |= ENQUEUE_REPLENISH;
> } else {
> - p->dl.pi_se = &p->dl;
> + dl_deboost(&p->dl);
> + /*
> + * dl_deboost() can start a new period. Its
> + * deadline can then be after the top waiter's.
> + * Boost the task again then.
> + */
> + if (pi_task && dl_prio(pi_task->prio) &&
> + dl_entity_preempt(&pi_task->dl, &p->dl)) {
> + p->dl.pi_se = pi_task->dl.pi_se;
> + scope->flags |= ENQUEUE_REPLENISH;
> + }
> }

[Severity: Medium]
Can a SCHED_DEADLINE task keep a departed donor's refilled runtime and
deadline when switching to another deadline top waiter?

Before this else branch, rt_mutex_setprio() checks
dl_entity_preempt(&pi_task->dl, &p->dl) against p->dl.deadline. If a
previous donor refilled p (setting p->dl.dl_donor_refill = 1) and pushed
p->dl.deadline past the next waiter pi_task->dl.deadline, that outer
check succeeds and skips dl_deboost(&p->dl). Because p->dl.dl_deadline
is non-zero and p->dl.runtime can still be positive from the previous
donor's refill, ENQUEUE_REPLENISH in replenish_dl_entity() does not reset
p->dl.runtime or p->dl.deadline, leaving p running with the previous
donor's remaining runtime and postponed deadline.

Calling dl_deboost(&p->dl) before testing dl_entity_preempt(&pi_task->dl,
&p->dl) for dl_prio(p->normal_prio) tasks would also avoid duplicating
the re-boost check in the else branch.

[ ... ]

> diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
> index 914915abb912d..66a1150c4811a 100644
> --- a/kernel/sched/deadline.c
> +++ b/kernel/sched/deadline.c

[ ... ]

> @@ -1150,6 +1187,7 @@ static void replenish_dl_entity(struct sched_dl_entity *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;

[Severity: Medium]
Should the (dl_se->runtime < 0 || dl_se->dl_yielded) path also call
dl_note_donor_refill(dl_se)?

When a boosted SCHED_DEADLINE task (dl_se->dl_deadline != 0) exhausts its
runtime or yields after its donor's parameters have been cleared, this
branch clamps dl_se->runtime to 0 and clears dl_se->dl_throttled without
recording the refill. At deboost, dl_deboost() sees
dl_se->dl_donor_refill == 0 and leaves the task queued with
dl_se->runtime == 0, so it throttles on the next tick instead of starting
a new period with its own reservation.

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