Re: [PATCH v14 12/39] sched/deadline: Leave a dying task out of a rebuild of the accounting

From: sashiko-bot

Date: Thu Dec 03 2026 - 11:20:55 EST


Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] sched/deadline: double dl_release_params() wipes constrained
deadline
--

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

sched/deadline: Leave a dying task out of a rebuild of the accounting

This commit skips dead deadline tasks with no recorded dl_bw_cpu in
dl_add_task_root_domain() so a root domain rebuild does not re-count
bandwidth that was already released before dl_bw was cleared.

> diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
> index 03a6699151cfe..fc0f32a7f80ac 100644
> --- a/kernel/sched/deadline.c
> +++ b/kernel/sched/deadline.c
> @@ -3861,6 +3861,17 @@ void dl_add_task_root_domain(struct task_struct *p)
> if (recorded < 0 || !cpu_active(recorded))
> goto unlock;
> cpu = recorded;
> + } else if (READ_ONCE(p->__state) == TASK_DEAD && p->dl.dl_bw_cpu < 0) {
> + /*
> + * Count nothing for a dead task with no record. Its last
> + * schedule released the bandwidth under its rq lock, and has
> + * not cleared dl_bw yet. The release clears the record under
> + * dl_departed_lock, which this walk holds. A dead task with a
> + * record has not reached its last schedule. Count it as a
> + * live task. That schedule then releases what the walk
> + * counted, or puts the task on the departed list.
> + */
> + goto unlock;
> }
> rq = cpu_rq(cpu);
> dl_b = &rq->rd->dl_bw;

[Severity: Medium]
In commit "sched/deadline: Keep the deadline of a departed constrained
task", can a second call to dl_release_params() wipe the preserved
dl_se->deadline of a constrained-deadline task?

When a constrained-deadline task has an armed inactive_timer that starts
running on CPU1 (making hrtimer_active() return true) before acquiring
task_rq_lock(), CPU0 can wake or PI-boost the task and leave
SCHED_DEADLINE via switched_from_dl() -> task_non_contending() first:

CPU0 CPU1
inactive_task_timer()
(hrtimer_active() is true)
switched_from_dl()
task_non_contending(..., false)
hrtimer_active() -> true
dl_task_release_bw(p)
dl_release_params(dl_se)
__dl_clear_params(dl_se)
dl_se->deadline = deadline
task_rq_lock(p, &rf)
!dl_task(p) -> true
dl_task_release_bw(p)
dl_release_params(dl_se)
dl_is_implicit() -> true (0 == 0)
__dl_clear_params(dl_se)
<-- dl_se->deadline wiped to 0

On the second call to dl_release_params(), dl_deadline and dl_period are
both 0, so dl_is_implicit() evaluates to true and __dl_clear_params()
overwrites the preserved dl_se->deadline with 0.

If the task re-enters SCHED_DEADLINE before its next period, it bypasses
dl_check_constrained_dl() throttling and can consume more than its
admitted bandwidth, potentially causing other deadline tasks to miss
deadlines.

Returning early from dl_release_params() when dl_se->dl_runtime is
already 0 would avoid wiping the preserved deadline.

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