Re: [PATCH v10 37/40] sched/deadline: Keep the start of the period across a change of dl_deadline
From: sashiko-bot
Date: Fri Nov 20 2026 - 16:21:58 EST
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] sched/deadline: replenish_dl_entity() keeps old dl_deadline
across periods
- [Medium] sched/deadline: dl_is_implicit() bypasses constrained gap on
dl_deadline growth
--
commit f729f2d93fa31589edb8491dd221ca94c6da13fe
Author: Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx>
sched/deadline: Keep the start of the period across a change of dl_deadline
This commit records the start of each deadline period in
sched_dl_entity::period_start and uses it in dl_next_period() and
dl_in_constrained_gap() so that mid-period changes to dl_deadline via
sched_setattr() do not shift the computed start of the next period.
> diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
> index b9c206a59c164..e9b3d3ec71d77 100644
> --- a/kernel/sched/deadline.c
> +++ b/kernel/sched/deadline.c
[ ... ]
> @@ -103,7 +104,7 @@ static inline bool dl_in_constrained_gap(struct sched_dl_entity *dl_se)
> u64 now = rq_clock(rq_of_dl_se(dl_se));
>
> return !dl_is_implicit(dl_se) && dl_time_before(dl_se->deadline, now) &&
> - dl_time_before(now, dl_se->deadline - dl_se->dl_deadline + dl_se->dl_period);
> + dl_time_before(now, dl_se->period_start + dl_se->dl_period);
> }
[Severity: Medium]
Can a constrained task whose dl_deadline is increased to equal dl_period
during an active period still bypass throttling in the gap between its
current deadline and its next period?
When sched_setattr() sets dl_deadline == dl_period mid-period,
dl_is_implicit(dl_se) becomes true while dl_se->deadline is still earlier
than dl_next_period(dl_se). Because dl_in_constrained_gap(),
enqueue_dl_entity(), update_dl_entity(), and dl_proxy_block() gate their
constrained-deadline checks on !dl_is_implicit(dl_se), a task waking
between dl_se->deadline and dl_next_period(dl_se) skips
dl_check_constrained_dl() and receives a new period and full runtime early
via replenish_dl_new_period():
kernel/sched/deadline.c:enqueue_dl_entity() {
...
if (!dl_se->dl_throttled && !dl_is_implicit(dl_se))
dl_check_constrained_dl(dl_se);
...
}
[ ... ]
> @@ -1425,6 +1429,7 @@ static void replenish_dl_entity(struct sched_dl_entity *dl_se)
> */
> while (dl_se->runtime <= 0) {
> dl_se->deadline += period;
> + dl_se->period_start += period;
> dl_se->runtime += runtime;
> }
[Severity: High]
Does advancing dl_se->deadline by period here keep the old relative
deadline offset across future periods after sched_setattr() changes
dl_deadline?
With start_dl_timer() now arming the replenishment timer at
dl_se->period_start + dl_se->dl_period instead of shifting by the old
dl_deadline, dl_se->deadline at replenishment time is still
period_start + old_dl_deadline. Adding period to both dl_se->period_start
and dl_se->deadline leaves dl_se->deadline at
new_period_start + old_dl_deadline instead of
dl_se->period_start + deadline, so subsequent periods continue using the
old relative deadline and can falsely throttle the task in
dl_check_constrained_dl() or grant a second replenishment mid-period in
update_dl_entity().
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1795207232.git.mathieu.desnoyers@xxxxxxxxxxxx?part=37