From: Ridong Chen <ridong.chen@linux.dev>
To: "Kyuwon Cho" <kyuwon.cho@skku.edu>,
"Waiman Long" <longman@redhat.com>, "Tejun Heo" <tj@kernel.org>,
"Johannes Weiner" <hannes@cmpxchg.org>,
"Michal Koutný" <mkoutny@suse.com>
Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] cgroup/cpuset: reject local partitions that overlap remote CPUs
Date: Fri, 4 Dec 2026 10:24:45 +0800 [thread overview]
Message-ID: <311db065-5f72-4f8a-9db0-341aea19fa28@linux.dev> (raw)
In-Reply-To: <179611520879.292090.13931935686523381061@skku.edu>
On 12/4/2026 12:45 AM, Kyuwon Cho wrote:
> An invalid local partition can have a remote descendant whose CPUs come
> from the top cpuset. When the local partition is made valid again,
> update_parent_effective_cpumask() derives its CPUs from the parent's
> effective_xcpus. That mask includes CPUs assigned to remote partitions,
> unlike the parent's effective_cpus mask.
>
Thanks for the report. I agree the overlap is real, but I think the fix
belongs in validate_partition() rather than in
update_parent_effective_cpumask().
The root cause is a missing check in partition validation: active CPUs
newly taken by a partition must come from the effective_cpus of its
parent (top_cpuset for a remote partition), i.e. they must not be owned
by another partition. The remote side already enforces this in
remote_partition_enable() via the subpartitions_cpus check, but the local
side does not, and only has the WARN_ON_ONCE() as a safety net.
> The code warns when the active CPUs are not available from the parent,
> but then continues and marks the local partition valid. This lets the
> local partition and its remote descendant own the same CPU:
>
> WARNING: kernel/cgroup/cpuset.c:2057 at update_parent_effective_cpumask
> RIP: update_parent_effective_cpumask (kernel/cgroup/cpuset.c:2057)
> Call Trace:
> cpuset_write_resmask (kernel/cgroup/cpuset.c:2622)
> cgroup_file_write (kernel/cgroup/cgroup.c:4426)
> kernfs_fop_write_iter (fs/kernfs/file.c:345)
> vfs_write (fs/read_write.c:575)
>
> The same condition is possible when a member cpuset containing a remote
> partition is enabled as a local partition. Reject both operations with
> PERR_NOCPUS instead of installing overlapping partition ownership.
>
> Fixes: 181c8e091aae ("cgroup/cpuset: Introduce remote partition")
> Signed-off-by: Kyuwon Cho <kyuwon.cho@skku.edu>
> ---
> The issue was found by an LLM-guided test generator that we are
> developing as a research prototype. The reproducer creates a cgroup2
> local partition and a remote descendant, invalidates the local
> partition, lets the remote partition take its CPU, and then attempts to
> recover the local partition through cpuset.cpus.exclusive. Without the
> patch both partitions become owners of the CPU and the kernel warns.
> With the patch recovery remains invalid with PERR_NOCPUS and no warning
> occurs.
>
> Found and tested on mainline fe6ff8d5d675 (v7.4-rc5); the patch is
> against the cgroup for-next tree at 7e16ab5a117a.
>
> kernel/cgroup/cpuset.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
> index 3e0ed61f3a88..236bb8f47bc1 100644
> --- a/kernel/cgroup/cpuset.c
> +++ b/kernel/cgroup/cpuset.c
> @@ -2016,7 +2016,8 @@ static int update_parent_effective_cpumask(struct cpuset *cs, int cmd,
> * Warn if it is not the case.
> */
> cpumask_and(tmp->new_cpus, tmp->delmask, cpu_active_mask);
> - WARN_ON_ONCE(!cpumask_subset(tmp->new_cpus, parent->effective_cpus));
> + if (!cpumask_subset(tmp->new_cpus, parent->effective_cpus))
> + return PERR_NOCPUS;
> deleting = true;
> } else if (cmd == partcmd_disable) {
> /*
> @@ -2082,7 +2083,11 @@ static int update_parent_effective_cpumask(struct cpuset *cs, int cmd,
> */
> if (deleting) {
> cpumask_and(tmp->new_cpus, tmp->delmask, cpu_active_mask);
> - WARN_ON_ONCE(!cpumask_subset(tmp->new_cpus, parent->effective_cpus));
> + if (!cpumask_subset(tmp->new_cpus,
> + parent->effective_cpus)) {
> + part_error = PERR_NOCPUS;
> + deleting = false;
> + }
This one is not right for a valid partition. In the partcmd_update with
newmask case, addmask has already been computed at this point. Clearing
only deleting leaves adding set, and write_error then turns the partition
invalid while partition_xcpus_del() gives back only addmask. The rest of
cs->effective_xcpus stays in subpartitions_cpus and out of the parent's
effective_cpus, owned by an invalid partition.
> }
> } else {
> /*
--
Best regards
Ridong
prev parent reply other threads:[~2026-12-04 2:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 16:45 [PATCH] cgroup/cpuset: reject local partitions that overlap remote CPUs Kyuwon Cho
2026-12-04 2:24 ` Ridong Chen [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=311db065-5f72-4f8a-9db0-341aea19fa28@linux.dev \
--to=ridong.chen@linux.dev \
--cc=cgroups@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=kyuwon.cho@skku.edu \
--cc=linux-kernel@vger.kernel.org \
--cc=longman@redhat.com \
--cc=mkoutny@suse.com \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox