Re: [PATCH v9 27/33] sched/deadline: Start a period at a deboost out of the class

From: sashiko-bot

Date: Fri Nov 20 2026 - 09:27:57 EST


Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] sched/deadline: uncanceled inactive_timer on asleep deboost
in dl_deboost()
--

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

sched/deadline: Start a period at a deboost out of the class

This commit starts a new period of the task's own reservation in
switched_from_dl() and cancels any armed inactive timer when a task that
was refilled from a donor during a boost leaves SCHED_DEADLINE.

> diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
> index c57bbc7a9536a..4c46a7aa27096 100644
> --- a/kernel/sched/deadline.c
> +++ b/kernel/sched/deadline.c
> @@ -83,6 +83,16 @@ static inline int on_dl_rq(struct sched_dl_entity *dl_se)
> return !RB_EMPTY_NODE(&dl_se->rb_node);
> }
>
> +/*
> + * Start a period of the reservation of @dl_se now. The caller holds the rq
> + * lock and has updated the rq clock.
> + */
> +static inline void dl_start_own_period(struct sched_dl_entity *dl_se)
> +{
> + dl_se->deadline = rq_clock(rq_of_dl_se(dl_se)) + dl_se->dl_deadline;
> + dl_se->runtime = dl_se->dl_runtime;
> +}
> +
> #ifdef CONFIG_RT_MUTEXES
> static inline struct sched_dl_entity *pi_of(struct sched_dl_entity *dl_se)
> {
> @@ -117,12 +127,8 @@ static inline void dl_note_donor_refill(struct sched_dl_entity *dl_se)
> */
> void dl_deboost(struct sched_dl_entity *dl_se)
> {
> - struct rq *rq = rq_of_dl_se(dl_se);
> -
> - if (dl_se->dl_donor_refill) {
> - dl_se->deadline = rq_clock(rq) + dl_se->dl_deadline;
> - dl_se->runtime = dl_se->dl_runtime;
> - }
> + if (dl_se->dl_donor_refill)
> + dl_start_own_period(dl_se);
> dl_drop_boost(dl_se);
> }

[ ... ]

> @@ -4629,6 +4637,19 @@ void dl_clear_root_domains(void)
>
> static void switched_from_dl(struct rq *rq, struct task_struct *p)
> {
> + bool own_period = p->dl.dl_runtime && p->dl.dl_donor_refill;
> +
> + /*
> + * The boost of a task with parameters of its own ends, and the task
> + * leaves the class. If the boost refilled its runtime from the
> + * donor's parameters, its runtime and deadline are not those of its
> + * reservation. task_non_contending() would mix them with its own
> + * dl_runtime and dl_period. Start a period of its own instead, as
> + * dl_deboost() does. Its 0-lag time is then now, or has passed.
> + */
> + if (own_period)
> + dl_start_own_period(&p->dl);
> +
> /*
> * task_non_contending() can start the "inactive timer" (if the 0-lag
> * time is in the future). If the task switches back to dl before
> @@ -4660,6 +4681,18 @@ static void switched_from_dl(struct rq *rq, struct task_struct *p)
> if (p->dl.dl_non_contending)
> sub_running_bw(&p->dl, &rq->dl);
> sub_rq_bw(&p->dl, &rq->dl);
> + /*
> + * The task blocked while boosted, after a refill from the
> + * donor. The timer armed then mixes the donor's runtime and
> + * deadline with the task's own parameters. Cancel it, and
> + * work out the 0-lag time of the period just started below.
> + * If the handler runs already, it releases the bandwidth.
> + */
> + if (own_period && p->dl.dl_non_contending &&
> + hrtimer_try_to_cancel(&p->dl.inactive_timer) == 1) {
> + p->dl.dl_non_contending = 0;
> + put_task_struct(p);
> + }

[Severity: Medium]
Should dl_deboost() also cancel inactive_timer and subtract running_bw
when a donor-refilled task is deboosted while asleep in SCHED_DEADLINE?

When a boosted SCHED_DEADLINE task blocks after a donor refill,
dequeue_dl_entity() -> task_non_contending() arms inactive_timer from the
mix of the donor's runtime/deadline and the task's own parameters, and
sets dl_non_contending = 1. If the boost ends while the task is still
asleep and remaining in SCHED_DEADLINE (for example, when the donor waiter
times out on the rt_mutex), rt_mutex_setprio() calls dl_deboost().
dl_deboost() starts a fresh period of the task's own reservation (whose
0-lag time is now) and clears dl_donor_refill via dl_drop_boost(), but
leaves the donor-mixed inactive_timer armed and dl_non_contending set.

This keeps rq->dl.running_bw inflated by the sleeping task's dl_bw until
the donor-mixed timer expires. Furthermore, if the sleeping task later
leaves SCHED_DEADLINE before that timer fires, switched_from_dl() sees
dl_donor_refill == 0 (own_period == false) and dl_non_contending == 1, so
it neither cancels inactive_timer nor calls task_non_contending() to
release the task's bandwidth from the root domain's total_bw.

--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1795181240.git.mathieu.desnoyers@xxxxxxxxxxxx?part=27