Re: [PATCH v4 09/26] sched/deadline: Reset the deadline and the runtime with the parameters

From: sashiko-bot

Date: Fri Nov 06 2026 - 21:19:02 EST


Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] sched/deadline: unreset donor period in switched_from_dl()
when dl_runtime != 0
- [Medium] sched/deadline: donor deadline and runtime kept on deboost
after setattr
--

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

sched/deadline: Reset the deadline and the runtime with the parameters

This commit resets dl_se->deadline and dl_se->runtime in
__dl_clear_params() and in switched_from_dl() when a deboosted task has no
dl_runtime of its own.

> diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
> index b8b0076870a64..f389620e6fc9a 100644
> --- a/kernel/sched/deadline.c
> +++ b/kernel/sched/deadline.c
> @@ -3580,6 +3580,16 @@ static void switched_from_dl(struct rq *rq, struct task_struct *p)
> if (task_on_rq_queued(p) && p->dl.dl_runtime)
> task_non_contending(&p->dl, false);
>
> + /*
> + * Deboosted from priority inheritance with no parameters of its own:
> + * the deadline and the runtime are the donor's. A change into the
> + * class then starts a period from the parameters it is given.
> + */
> + if (!p->dl.dl_runtime) {
> + p->dl.deadline = 0;
> + p->dl.runtime = 0;
> + }

[Severity: Medium]
What happens in switched_from_dl() when a task that still carries pre-0-lag
parameters (p->dl.dl_runtime != 0) is PI-boosted by a SCHED_DEADLINE waiter
and then deboosted?

When the task is boosted before its inactive_timer fires, switched_to_dl()
cancels inactive_timer and replenish_dl_entity() overwrites p->dl.deadline
and p->dl.runtime from the donor's pi_params. On deboost, p->dl.dl_runtime
is non-zero, so switched_from_dl() skips the reset and passes the
donor-modified deadline and runtime to task_non_contending(), mixing them
with the task's old dl_period and dl_runtime.

Depending on the donor's parameters, this either releases the task's old
bandwidth before its real 0-lag time or leaves the donor's future deadline
and runtime in place for a subsequent entry into SCHED_DEADLINE.

[Severity: Medium]
Can a task keep the donor's deadline and runtime if sched_setattr() gives
it SCHED_DEADLINE parameters while it is PI-boosted?

If a non-deadline task is boosted into dl_sched_class and then configured
as SCHED_DEADLINE via sched_setattr() before unlocking the rt_mutex, both
__sched_setscheduler() and the subsequent deboost in rt_mutex_setprio()
keep the task in dl_sched_class without calling switched_from_dl():

kernel/sched/core.c:rt_mutex_setprio() {
...
} else {
p->dl.dl_boosted = 0;
}
...
}

When rt_mutex_setprio() clears dl_boosted, enqueue_dl_entity() only calls
setup_new_dl_entity() if dl_se->deadline is already in the past, so the
task runs unboosted on the donor's remaining runtime and deadline instead
of starting a period from its own parameters.

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