Re: [PATCH v9 15/33] sched/deadline: Keep a task in the root domain that counts its bandwidth
From: sashiko-bot
Date: Fri Nov 20 2026 - 09:12:32 EST
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] sched/deadline: dl_task_offline_migration() ignores span on
inactive cpus_ptr
--
commit 30bbbaf8a09d1e3ee2bdeb94517ef4083cc36f04
Author: Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx>
sched/deadline: Keep a task in the root domain that counts its bandwidth
This commit adds dl_task_bw_span() and dl_bw_def tracking so that CPU
selection paths keep a deadline task and its bandwidth in the root domain
that admitted it.
> diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
> index 3942464be30b4..d84c403cc8223 100644
> --- a/kernel/sched/deadline.c
> +++ b/kernel/sched/deadline.c
[ ... ]
> @@ -956,18 +975,36 @@ static struct rq *find_lock_later_rq(struct task_struct *task, struct rq *rq);
>
> static struct rq *dl_task_offline_migration(struct rq *rq, struct task_struct *p)
> {
> + const struct cpumask *span;
> struct rq *later_rq = NULL;
> struct dl_bw *dl_b;
>
> later_rq = find_lock_later_rq(p, rq);
> + /*
> + * find_lock_later_rq() looks in the root domain of @rq. Once @rq is
> + * offline, a rebuild attaches it to def_root_domain. That root domain
> + * may not count @p. Do not take @p out of the root domain that counts
> + * it while @p has an active CPU there.
> + */
> + span = dl_task_bw_span(p);
> + if (later_rq && span && !cpumask_test_cpu(later_rq->cpu, span) &&
> + cpumask_first_and_and(cpu_active_mask, p->cpus_ptr, span) < nr_cpu_ids) {
> + double_unlock_balance(rq, later_rq);
> + later_rq = NULL;
> + }
> if (!later_rq) {
> int cpu;
>
> /*
> * If we cannot preempt any rq, fall back to pick any
> - * online CPU:
> + * online CPU. Try the root domain that counts @p first.
> */
> - cpu = cpumask_any_and(cpu_active_mask, p->cpus_ptr);
> + cpu = nr_cpu_ids;
> + if (span)
> + cpu = cpumask_first_and_and(cpu_active_mask,
> + p->cpus_ptr, span);
> + if (cpu >= nr_cpu_ids)
> + cpu = cpumask_any_and(cpu_active_mask, p->cpus_ptr);
> if (cpu >= nr_cpu_ids) {
> /*
> * Failed to find any suitable CPU.
> * The task will never come back!
> */
> WARN_ON_ONCE(dl_bandwidth_enabled());
>
> /*
> * If admission control is disabled we
> * try a little harder to let the task
> * run.
> */
> cpu = cpumask_any(cpu_active_mask);
> }
[Severity: Medium]
Should dl_task_offline_migration() also fall back to an active CPU in span
when p->cpus_ptr has no active CPUs left?
In sched_cpu_deactivate(), set_cpu_active(cpu, false) and
sched_set_rq_offline() run before cpuset_cpu_inactive() updates task
cpumasks for a cpuset whose last active CPU just went offline. If
dl_task_timer() fires in that window for a throttled task on the offlining
runqueue, p->cpus_ptr has no active CPUs even though span still has active
CPUs.
Because dl_task_offline_migration() only intersects span with p->cpus_ptr,
it triggers WARN_ON_ONCE(dl_bandwidth_enabled()) and falls back to
cpumask_any(cpu_active_mask). With isolcpus=domain,0,1, that can pick an
isolated CPU in def_root_domain and move p->dl.dl_bw into another root
domain without an admission check.
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1795181240.git.mathieu.desnoyers@xxxxxxxxxxxx?part=15