Re: [PATCH v6 33/37] sched/deadline: Check the runtime of a task whose parameters change

From: sashiko-bot

Date: Mon Nov 16 2026 - 15:05:22 EST


Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] sched/deadline: dl_new_params cleared while boosted in
enqueue_dl_entity()
- [Medium] sched/deadline: unchecked laxity in update_dl_entity() on
dl_deadline shrink
--

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

sched/deadline: Check the runtime of a task whose parameters change

This commit adds a dl_new_params flag to struct sched_dl_entity so that
when sched_setattr() modifies a deadline task's runtime, deadline, or
period, the next enqueue checks the remaining runtime against the new
parameters via update_dl_entity().

> diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
> index b47c13c8714d9..3b62ee43c2099 100644
> --- a/kernel/sched/deadline.c
> +++ b/kernel/sched/deadline.c
> @@ -2674,7 +2674,10 @@ static void __dequeue_dl_entity(struct sched_dl_entity *dl_se)
> static void
> enqueue_dl_entity(struct sched_dl_entity *dl_se, int flags)
> {
> + bool new_params = dl_se->dl_new_params;
> +
> WARN_ON_ONCE(on_dl_rq(dl_se));
> + dl_se->dl_new_params = 0;

[Severity: Medium]
Does clearing dl_se->dl_new_params unconditionally here lose the mark if
the task is priority-inheritance boosted when sched_setattr() shrinks its
reservation?

When is_dl_boosted(dl_se) is true, the new_params branch below is skipped
(or on a wakeup while boosted, update_dl_entity() checks against
pi_of(dl_se) rather than the task's own parameters). If the boost took no
donor refill (dl_donor_refill == 0), dl_deboost() later leaves
dl_se->runtime and dl_se->deadline intact, and the subsequent enqueue sees
dl_se->dl_new_params == 0 and lets the task run on its old larger runtime
after admission control already released the bandwidth difference.

> update_stats_enqueue_dl(dl_rq_of_se(dl_se), dl_se, flags);
>
> @@ -2723,12 +2726,13 @@ enqueue_dl_entity(struct sched_dl_entity *dl_se, int flags)
> update_dl_entity(dl_se);
> } else if (flags & ENQUEUE_REPLENISH) {
> replenish_dl_entity(dl_se);
> - } else if ((flags & ENQUEUE_CLASS) && !is_dl_boosted(dl_se)) {
> + } else if (((flags & ENQUEUE_CLASS) || new_params) &&
> + !is_dl_boosted(dl_se)) {
> /*
> - * The task enters the class runnable. It may come back before
> - * its deadline, with the runtime left from older parameters.
> - * Check that runtime against the new parameters, as a wakeup
> - * does.
> + * The task enters the class, or its parameters change, while
> + * it is runnable. It may have runtime left from older
> + * parameters. Check that runtime against the new parameters,
> + * as a wakeup does.
> */
> update_dl_entity(dl_se);

[Severity: Medium]
Can update_dl_entity() leave or set dl_se->runtime above the new
dl_se->dl_runtime when sched_setattr() shrinks dl_deadline to a
constrained reservation while dl_se->deadline - rq_clock(rq) still exceeds
the new dl_deadline?

Both dl_entity_overflow() and update_dl_revised_wakeup() assume that
laxity = dl_se->deadline - rq_clock(rq) is at most dl_se->dl_deadline:

kernel/sched/deadline.c:update_dl_revised_wakeup() {
u64 laxity = dl_se->deadline - rq_clock(rq);

WARN_ON(dl_time_before(dl_se->deadline, rq_clock(rq)));

dl_se->runtime = (dl_se->dl_density * laxity) >> BW_SHIFT;
}

For example, if a task running at 50ms/100ms/100ms has runtime = 30ms and
laxity = 80ms when changed to 10ms/20ms/100ms (density 50%),
dl_entity_overflow() sees 30ms / 80ms <= 10ms / 20ms and leaves runtime at
30ms; if changed instead at runtime = 49ms and laxity = 99ms to
8ms/20ms/100ms (density 40%), update_dl_revised_wakeup() sets
dl_se->runtime to 39.6ms against an 8ms budget. Besides letting the task
overrun the bandwidth it just gave back in sched_dl_overflow(), blocking
with dl_se->runtime > dl_se->dl_runtime makes task_non_contending()
compute a negative zerolag_time and drop running_bw or total_bw
immediately.

--
Sashiko AI review · https://sashiko.dev/#/patchset/20261116190549.230119-1-mathieu.desnoyers@xxxxxxxxxxxx?part=33