Re: [PATCH v8 03/33] sched/deadline: Record the root domain holding a task's bandwidth

From: sashiko-bot

Date: Thu Nov 19 2026 - 15:52:05 EST


Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] sched/deadline: __sched_setscheduler() checks task_rq(p)->rd
instead of dl_bw_cpu
--

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

sched/deadline: Record the root domain holding a task's bandwidth

This commit records a CPU from the root domain accounting a deadline
task's bandwidth in dl_bw_cpu and uses it across bandwidth moves,
releases, parameter updates, and affinity checks.

Link: https://lore.kernel.org/all/20261103-b4-sched-dl-bw-fixes-v1-1-dd761fe005b4@xxxxxxxxxx/

> diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
> index 585070a9d3171..5a8f38632e545 100644
> --- a/kernel/sched/deadline.c
> +++ b/kernel/sched/deadline.c
[ ... ]
> @@ -4203,6 +4270,23 @@ int sched_dl_overflow(struct task_struct *p, int policy,
> if (new_bw == p->dl.dl_bw && task_has_dl_policy(p))
> return 0;
>
> + /*
> + * Change the bandwidth of a deadline task where it is counted: in
> + * the root domain of the CPU recorded with it. A task moved asleep
> + * has not run there yet, so the CPU it is on can be elsewhere. No
> + * bandwidth is counted if a rebuild dropped it, or if the task
> + * enters the class. A runtime below about a millionth of the period
> + * gives a bandwidth of 0. It counts for nothing, and no move updates
> + * its record. In these three cases, the root domain of the CPU the
> + * task is on takes the new bandwidth. The caller holds cpuset_mutex,
> + * or dl_accounting_mutex without cpusets, so no rebuild runs
> + * meanwhile.
> + */
> + counted = task_has_dl_policy(p) && p->dl.dl_bw_cpu >= 0 &&
> + p->dl.dl_bw_gen == dl_bw_gen;
> + cpu = counted && p->dl.dl_bw ? p->dl.dl_bw_cpu : task_cpu(p);
> + dl_b = dl_bw_of(cpu);

[Severity: Medium]
Should the root domain check in __sched_setscheduler() also use the
recorded dl_bw_cpu instead of rq->rd?

kernel/sched/syscalls.c:__sched_setscheduler() {
...
if (dl_bandwidth_enabled() && dl_policy(policy) &&
!(attr->sched_flags & SCHED_FLAG_SUGOV)) {
cpumask_t *span = rq->rd->span;

if (!cpumask_subset(span, &p->cpus_mask) ||
rq->rd->dl_bw.bw == 0) {
retval = -EPERM;
goto unlock;
}
}
...
}

When a sleeping SCHED_DEADLINE task is moved to another cpuset partition,
p->cpus_mask is updated to the new root domain while task_rq(p) remains in
the old root domain until wakeup. Because the old rq->rd->span is not a
subset of p->cpus_mask, __sched_setscheduler() rejects sched_setattr()
parameter changes with -EPERM before reaching sched_dl_overflow().

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