Re: [PATCH v6 32/37] sched/deadline: Check the runtime of a task that comes back runnable
From: sashiko-bot
Date: Mon Nov 16 2026 - 15:08:55 EST
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] sched/deadline: missed update_dl_entity() when setattr runs
while PI-boosted
--
commit d9e5d198497bbfbacaaacba33587790f1f7b2f0f
Author: Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx>
sched/deadline: Check the runtime of a task that comes back runnable
This commit calls update_dl_entity() when a runnable unboosted task enters
SCHED_DEADLINE so its remaining runtime is checked against its new
scheduling parameters.
> diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
> index ffa8b946e8047..b47c13c8714d9 100644
> --- a/kernel/sched/deadline.c
> +++ b/kernel/sched/deadline.c
> @@ -2723,6 +2723,14 @@ 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)) {
> + /*
> + * 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.
> + */
> + update_dl_entity(dl_se);
> } else if ((flags & ENQUEUE_MOVE) &&
> !is_dl_boosted(dl_se) &&
> dl_time_before(dl_se->deadline, rq_clock(rq_of_dl_se(dl_se)))) {
[Severity: Medium]
Can a runnable task bypass update_dl_entity() when returning to
SCHED_DEADLINE with smaller runtime if it is PI-boosted at the time of
sched_setattr()?
If a SCHED_DEADLINE task switches to SCHED_OTHER before its 0-lag time and
is then PI-boosted back into dl_sched_class by an rt_mutex waiter,
replenish_dl_entity() sees non-zero dl_se->dl_deadline and positive
dl_se->runtime, so dl_se->dl_donor_refill stays 0.
When sched_setattr() then returns the task to SCHED_DEADLINE with a
smaller runtime while still boosted, __sched_setscheduler() sees
prev_class == next_class == &dl_sched_class (so ENQUEUE_CLASS is not set)
and is_dl_boosted(dl_se) is true, skipping update_dl_entity(). Even with
commit "sched/deadline: Check the runtime of a task whose parameters
change", enqueue_dl_entity() clears dl_se->dl_new_params unconditionally
at the top while skipping the check because is_dl_boosted(dl_se) is true.
When the task later unlocks the rt_mutex, dl_deboost() sees
dl_donor_refill == 0 and leaves the old larger dl_se->runtime intact:
kernel/sched/deadline.c:dl_deboost() {
if (dl_se->dl_donor_refill) {
dl_se->deadline = rq_clock(rq) + dl_se->dl_deadline;
dl_se->runtime = dl_se->dl_runtime;
}
dl_drop_boost(dl_se);
}
Because the subsequent enqueue only passes ENQUEUE_MOVE with a future
deadline, update_dl_entity() is never called, and the task runs on its old
larger runtime while admission control only accounts for the new smaller
bandwidth.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261116190549.230119-1-mathieu.desnoyers@xxxxxxxxxxxx?part=32