Re: [PATCH v11 16/43] sched/deadline: Keep the last CPU a task has in its root domain

From: sashiko-bot

Date: Wed Nov 25 2026 - 20:35:52 EST


Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] cgroup/cpuset: wrong v1 ancestor walk in
cpuset_cpus_allowed_without()
--

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

sched/deadline: Keep the last CPU a task has in its root domain

This commit refuses CPU offline operations with -EBUSY when taking the CPU
offline would move a SCHED_DEADLINE task out of the root domain that
admitted its bandwidth.

> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
> index 7bdb9e21a7edb..37d04b08996ec 100644
> --- a/kernel/cgroup/cpuset.c
> +++ b/kernel/cgroup/cpuset.c
[ ... ]
> @@ -4312,6 +4334,292 @@ void cpuset_cpus_allowed(struct task_struct *tsk, struct cpumask *pmask)
> spin_unlock_irqrestore(&callback_lock, flags);
> }
>
[ ... ]
> +bool cpuset_cpus_allowed_without(struct task_struct *tsk, int cpu,
> + struct cpumask *pmask)
> +{
> + const struct cpumask *possible = task_cpu_possible_mask(tsk);
> + struct cpuset *cs = task_cs(tsk), *from, *gone = NULL;
> +
> + guard(rcu)();
> + if (!is_in_v2_mode()) {
> + /*
> + * cgroup v1 moves the tasks of a cpuset left with no CPU to
> + * the nearest ancestor that keeps one.
> + */
> + for (from = cs; from; from = parent_cs(from)) {
> + cpumask_and(pmask, from->effective_cpus, cpu_active_mask);
> + cpumask_clear_cpu(cpu, pmask);
> + if (cpumask_intersects(pmask, possible))
> + break;
> + }

[Severity: Medium]
Should the cgroup v1 loop break on !cpumask_empty(pmask) instead of
cpumask_intersects(pmask, possible)?

On cgroup v1, cpuset1_hotplug_update_tasks() only considers a cpuset empty
and moves its tasks to an ancestor when cs->cpus_allowed becomes completely
empty:

kernel/cgroup/cpuset-v1.c:cpuset1_hotplug_update_tasks() {
...
is_empty = cpumask_empty(cs->cpus_allowed) ||
nodes_empty(cs->mems_allowed);
...
if (is_empty)
remove_tasks_in_empty_cpuset(cs);
}

On systems with asymmetric 32-bit support where task_cpu_possible_mask(tsk)
is a subset of cpu_possible_mask, a cpuset can retain active 64-bit-only
CPUs after the offline while having no CPUs left in possible. In that case
cgroup v1 leaves the task in cs and falls back to select_fallback_rq(),
whereas this loop walks up to parent_cs(from) and can return an ancestor's
32-bit-capable CPUs in pmask, allowing dl_task_leaves_span() to accept an
offline that moves a deadline task to another root domain or reject a valid
one with -EBUSY.

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