Re: [PATCH v8 32/33] sched/deadline: Check the runtime of a task whose parameters change
From: sashiko-bot
Date: Thu Nov 19 2026 - 15:59:15 EST
Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [Medium] sched/deadline: dl_deboost() skips dl_check_constrained_dl()
and sleep check
- [Medium] sched/deadline: __setparam_dl() skips dl_new_params on
boosted policy re-entry
- [Medium] sched/deadline: stale deadline in rt_mutex_adjust_pi() on
blocked param change
- [Medium] sched/deadline: missing PI boost when update_dl_entity()
pushes owner deadline
--
commit ef8688347a9187823ad70d72973343acbfec2dd5
Author: Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx>
sched/deadline: Check the runtime of a task whose parameters change
This commit marks deadline tasks whose runtime, deadline, or period
changes in __setparam_dl() and runs update_dl_entity() on the next
unboosted enqueue or upon deboost in dl_deboost().
> diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
> index 7ed2f525b883e..2849484428c60 100644
> --- a/kernel/sched/deadline.c
> +++ b/kernel/sched/deadline.c
[ ... ]
> @@ -130,6 +136,12 @@ void dl_deboost(struct sched_dl_entity *dl_se)
> if (dl_se->dl_donor_refill)
> dl_start_own_period(dl_se);
> dl_drop_boost(dl_se);
> +
> + if (dl_se->dl_new_params) {
> + dl_se->dl_new_params = 0;
> + if (!dl_se->dl_throttled)
> + update_dl_entity(dl_se);
> + }
> }
[Severity: Medium]
Does calling update_dl_entity() directly from dl_deboost() bypass
dl_check_constrained_dl() and update sleeping tasks prematurely?
In enqueue_dl_entity(), dl_check_constrained_dl() runs before
update_dl_entity() so a constrained task (!dl_is_implicit(dl_se)) with
dl_se->deadline < rq_clock(rq) < dl_next_period(dl_se) is throttled until
its next period. Because rt_mutex_setprio() calls dl_deboost() before
sched_change_end() enqueues the task, update_dl_entity() sees
dl_time_before(dl_se->deadline, rq_clock(rq)) and immediately starts a new
period via replenish_dl_new_period(), moving dl_se->deadline into the
future before enqueue_dl_entity() can throttle it.
In addition, if the lock owner is sleeping on a non-PI wait when a donor
times out or is interrupted (!task_on_rq_queued(p) &&
!dl_task_pi_blocked(p)), dl_deboost() clears dl_new_params and starts a
new period while the task is still asleep rather than waiting for its
wakeup enqueue.
[ ... ]
> @@ -2913,12 +2934,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);
> } else if ((flags & ENQUEUE_MOVE) &&
[Severity: Medium]
Can an unboosted SCHED_DEADLINE lock owner miss a required PI boost when
update_dl_entity() pushes its deadline past its top waiter's deadline?
Suppose a SCHED_DEADLINE task p holds an rt_mutex with a SCHED_DEADLINE
waiter whose deadline is later than p->dl.deadline, so p is not boosted.
When sched_setattr() shrinks p's reservation, __setscheduler_dl_pi() runs
before sched_change_end() and only checks !dl_policy(policy). Then
enqueue_dl_entity() calls update_dl_entity(), which starts a new period
and advances p->dl.deadline past the waiter's deadline. Unlike
rt_mutex_setprio(), which rechecks dl_entity_preempt(&pi_task->dl, &p->dl)
after dl_deboost(), __sched_setscheduler() never compares p's new deadline
against rt_mutex_get_top_task(p), leaving p unboosted and allowing it to
be throttled on its reduced runtime while holding the lock.
[ ... ]
> @@ -4971,6 +4993,11 @@ void __setparam_dl(struct task_struct *p, const struct sched_attr *attr)
> u64 period = attr->sched_period ?: attr->sched_deadline;
> bool held;
>
> + if (attr->sched_runtime != dl_se->dl_runtime ||
> + attr->sched_deadline != dl_se->dl_deadline ||
> + period != dl_se->dl_period)
> + dl_se->dl_new_params = 1;
> +
> /*
> * Change the bandwidth that the runqueue counts here, with the
> * parameters. A task that priority inheritance boosted into the
[Severity: Medium]
Does __setparam_dl() leave dl_new_params unset when a task leaves
SCHED_DEADLINE and re-enters with the same parameters while PI-boosted?
When a SCHED_DEADLINE task switches to another policy while PI-boosted (or
switches before its 0-lag time and is then PI-boosted back into
dl_sched_class, where switched_to_dl() cancels inactive_timer), its old
dl_runtime, dl_deadline, dl_period, runtime, and deadline remain in p->dl.
If the task still has positive runtime so replenish_dl_entity() does not
set dl_donor_refill, and sched_setattr() switches it back to
SCHED_DEADLINE with identical parameters while still boosted, prev_class
and next_class are both &dl_sched_class (so ENQUEUE_CLASS is not set) and
the parameter comparison above is false. At deboost, dl_deboost() sees
both dl_donor_refill == 0 and dl_new_params == 0 and skips
update_dl_entity(), letting the task consume its old leftover runtime
before the old deadline.
[Severity: Medium]
When sched_setattr() shrinks the parameters of an unboosted task blocked
on an rt_mutex, does rt_mutex_adjust_pi() use a stale p->dl.deadline?
For a task blocked waiting on an rt_mutex (dl_task_pi_blocked(p) is true
and task_on_rq_queued(p) is false), sched_change_end() does not call
enqueue_task_dl(); prio_changed_dl() returns early because the task is not
queued, and switched_to_dl() only replenishes when p->dl.deadline is
already in the past:
kernel/sched/deadline.c:switched_to_dl() {
...
if (dl_task_pi_blocked(p) && !p->dl.dl_throttled &&
dl_time_before(p->dl.deadline, rq_clock(rq)))
replenish_dl_new_period(&p->dl, rq);
...
}
When __sched_setscheduler() then calls rt_mutex_adjust_pi(p),
dl_new_params is still pending and update_dl_entity() has not run, so an
overflowing remaining runtime does not advance p->dl.deadline to a new
period before the waiter tree and lock owner boost are updated.
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1795116790.git.mathieu.desnoyers@xxxxxxxxxxxx?part=32