Re: [PATCH v12 34/43] sched/deadline: Cancel the replenishment timer with the parameters
From: sashiko-bot
Date: Fri Nov 27 2026 - 12:31:22 EST
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] sched/deadline: dl_task_timer() extends departed constrained
task by a period
--
commit 5761a4e5c3f4329860b62244eb1a4d3665aa6ab4
Author: Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx>
sched/deadline: Cancel the replenishment timer with the parameters
This commit cancels dl_se->dl_timer in task_non_contending() and
inactive_task_timer() when releasing a task's bandwidth and clearing its
SCHED_DEADLINE parameters.
> diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
> index 3eeb4c5cd924d..94d2b962208e7 100644
> --- a/kernel/sched/deadline.c
> +++ b/kernel/sched/deadline.c
> @@ -993,6 +993,7 @@ static void task_non_contending(struct sched_dl_entity *dl_se, bool dl_task)
> if (dl_task && READ_ONCE(p->__state) == TASK_DEAD)
> sub_rq_bw(dl_se, &rq->dl);
> dl_task_release_bw(p);
> + cancel_replenish_timer(dl_se);
> __dl_clear_params(dl_se);
> }
> }
> @@ -2932,6 +2933,7 @@ static enum hrtimer_restart inactive_task_timer(struct hrtimer *timer)
> }
>
> dl_task_release_bw(p);
> + cancel_replenish_timer(dl_se);
> __dl_clear_params(dl_se);
>
> goto unlock;
[Severity: Medium]
Can dl_task_timer() advance dl_next_period(dl_se) before cancel_replenish_timer()
is reached, extending a departed constrained task's bandwidth reservation by
an extra period?
In this series, commit "sched/deadline: Count the 0-lag time from the next
period" counts the 0-lag time from dl_next_period(dl_se), and commit
"sched/deadline: Keep a departing constrained task until its next period"
keeps a non-dying departing constrained task until at least
dl_next_period(dl_se) in both task_non_contending() and
inactive_task_timer() without cancelling dl_se->dl_timer.
When a constrained task is throttled in period [0, P] (with dl_timer armed
for P) and leaves SCHED_DEADLINE before P, dl_timer fires at P before
inactive_timer (either because dl_timer was queued earlier for expiry at P,
or because an overrun placed the 0-lag time after P):
kernel/sched/deadline.c:dl_task_timer() {
...
if (!dl_task(p)) {
if (dl_se->dl_throttled && !is_dl_boosted(dl_se)) {
sched_clock_tick();
update_rq_clock(rq);
replenish_dl_entity(dl_se);
}
goto unlock;
}
...
}
replenish_dl_entity() advances dl_se->deadline by dl_period, moving
dl_next_period(dl_se) to 2*P. When inactive_task_timer() (or
task_non_contending() if the task slept in SCHED_DEADLINE past P and then
left) subsequently runs, it sees dl_next_period(dl_se) - rq_clock(rq) > 0
and restarts inactive_timer for 2*P instead of reaching
dl_task_release_bw(), cancel_replenish_timer(), and __dl_clear_params().
The departed task's bandwidth stays locked in dl_b->total_bw for an extra
full period [P, 2*P], and if the task re-enters SCHED_DEADLINE in
(P + dl_deadline, 2*P) it is throttled with zero runtime until 2*P even
though it never ran in [P, 2*P].
Also, the commit message says that a constrained-deadline task that overran
by little reaches its 0-lag time before the end of its period and has its
timer cancelled at the 0-lag time, which does not match counting the 0-lag
time from dl_next_period(dl_se) and keeping departing constrained tasks
until dl_next_period(dl_se).
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1795771147.git.mathieu.desnoyers@xxxxxxxxxxxx?part=34