Re: [PATCH v7 10/40] sched/deadline: Reset the deadline and the runtime with the parameters
From: sashiko-bot
Date: Tue Nov 17 2026 - 09:58:33 EST
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] sched/deadline: donor runtime kept in switched_from_dl() when
dl_runtime != 0
--
commit c6cd5264704d8a0de90183dbd3576cbeaa15e19c
Author: Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx>
sched/deadline: Reset the deadline and the runtime with the parameters
This commit resets a deadline entity's dynamic deadline and runtime in
__dl_clear_params() and in switched_from_dl() when a boosted task with no
parameters of its own leaves SCHED_DEADLINE, so that its next entry into
the class starts a new period.
> diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
> index 71b1c155c2424..d6d2657dcddd6 100644
> --- a/kernel/sched/deadline.c
> +++ b/kernel/sched/deadline.c
> @@ -3569,6 +3569,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);
>
> + /*
> + * A task with no parameters of its own was boosted into the class.
> + * Its deadline and runtime are the donor's. Reset them, so that its
> + * next entry into the class starts a new period.
> + */
> + if (!p->dl.dl_runtime) {
> + p->dl.deadline = 0;
> + p->dl.runtime = 0;
> + }
[Severity: Medium]
Can a task deboosting via switched_from_dl() still retain a donor's
deadline and runtime when p->dl.dl_runtime is non-zero?
If a SCHED_DEADLINE task holding an rt_mutex contended by a deadline
waiter changes policy to SCHED_OTHER, __setscheduler_dl_pi() keeps it
boosted in dl_sched_class with its non-zero p->dl.dl_runtime while setting
p->dl.pi_se to the donor. When its runtime is replenished while boosted,
replenish_dl_new_period() refills p->dl.deadline and p->dl.runtime from
the donor's reservation.
At unlock, rt_mutex_setprio() invokes switched_from_dl() before calling
dl_drop_boost(&p->dl). Because p->dl.dl_runtime is non-zero,
switched_from_dl() skips resetting p->dl.deadline and p->dl.runtime, and
task_non_contending() computes zerolag_time by mixing the donor's dynamic
deadline and runtime with p's static dl_period and dl_runtime. If the
donor's runtime makes zerolag_time negative, task_non_contending() clears
p's bandwidth and parameters before its true 0-lag time; otherwise, p
keeps the donor's runtime and can consume it on top of its own reservation
if it re-enters SCHED_DEADLINE before the inactive timer fires.
Commits "sched/deadline: Reset the donor's runtime at a deboost in the
class" and "sched/deadline: Check the runtime of a task whose parameters
change" later in this series handle deboosts that stay in dl_sched_class,
but do not cover leaving dl_sched_class via switched_from_dl() with
non-zero p->dl.dl_runtime.
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1794922146.git.mathieu.desnoyers@xxxxxxxxxxxx?part=10