Re: [PATCH v11 34/43] sched/deadline: Cancel the replenishment timer with the parameters
From: sashiko-bot
Date: Wed Nov 25 2026 - 20:46:06 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 b4f4668865f16f00f3ee081d72d2725e00494e96
Author: Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx>
sched/deadline: Cancel the replenishment timer with the parameters
This commit cancels a task's deadline replenishment timer alongside
clearing its deadline parameters in task_non_contending() and
inactive_task_timer().
> diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
> index c59953e80b1a9..828923a771076 100644
> --- a/kernel/sched/deadline.c
> +++ b/kernel/sched/deadline.c
[ ... ]
> @@ -2895,6 +2896,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() fire before inactive_task_timer() at
dl_next_period(dl_se) for a departed constrained-deadline task, pushing
its bandwidth release and parameter reset out by an extra period?
When a constrained-deadline task is throttled without a runtime overrun
(for example via sched_yield()), start_dl_timer() queues dl_se->dl_timer
for dl_next_period(dl_se). If the task then leaves SCHED_DEADLINE,
task_non_contending() or inactive_task_timer() queues
dl_se->inactive_timer for that same dl_next_period(dl_se) timestamp
without cancelling dl_timer. Because dl_timer was queued in the hrtimer
tree first, it fires first at dl_next_period(dl_se):
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. When
inactive_task_timer() runs right after, it sees
dl_next_period(dl_se) - rq_clock(rq) == dl_period > 0 and returns
HRTIMER_RESTART instead of reaching dl_task_release_bw(),
cancel_replenish_timer(), and __dl_clear_params():
kernel/sched/deadline.c:inactive_task_timer() {
...
if (!dl_task(p) && READ_ONCE(p->__state) != TASK_DEAD &&
!dl_is_implicit(dl_se)) {
s64 left = dl_next_period(dl_se) - rq_clock(rq);
if (left > 0) {
ktime_t at = ktime_add_ns(hrtimer_cb_get_time(timer), left);
hrtimer_set_expires(timer, at);
task_rq_unlock(rq, p, &rf);
return HRTIMER_RESTART;
}
}
...
}
The departed task's bandwidth remains locked in dl_b->total_bw for an
extra period, and if the task returns to SCHED_DEADLINE after the phantom
deadline it is throttled with zero runtime until that extra period ends.
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1795646914.git.mathieu.desnoyers@xxxxxxxxxxxx?part=34