From: Guopeng Zhang <guopeng.zhang@linux.dev>
To: Waiman Long <longman@redhat.com>, Tejun Heo <tj@kernel.org>,
Ridong Chen <ridong.chen@linux.dev>
Cc: "Johannes Weiner" <hannes@cmpxchg.org>,
"Michal Koutný" <mkoutny@suse.com>,
cgroups@vger.kernel.org, linux-kernel@vger.kernel.org,
"Guopeng Zhang" <zhangguopeng@kylinos.cn>
Subject: [PATCH 2/2] cgroup/cpuset: Fix invalid local partition recovery
Date: Sat, 10 Oct 2026 15:59:47 +0800 [thread overview]
Message-ID: <20261010075947.333549-3-guopeng.zhang@linux.dev> (raw)
In-Reply-To: <20261010075947.333549-1-guopeng.zhang@linux.dev>
From: Guopeng Zhang <zhangguopeng@kylinos.cn>
An invalid local partition may fail to recover after its exclusive CPU
list is changed to a valid one.
This can be reproduced on a cgroup v2 system with CPUs 0-7 online:
cd /sys/fs/cgroup
echo +cpuset > cgroup.subtree_control
mkdir A
echo 0-7 > A/cpuset.cpus
echo 0-7 > A/cpuset.cpus.exclusive
echo root > A/cpuset.cpus.partition
cat A/cpuset.cpus.partition
echo 1 > A/cpuset.cpus.exclusive
cat A/cpuset.cpus.partition
The first read reports root invalid because all CPUs were requested.
After the mask is changed to CPU 1, the partition should become valid,
but it remains invalid with PERR_NOCPUS.
update_exclusive_cpumask() calls partition_cpus_change() before updating
cs->exclusive_cpus. update_parent_effective_cpumask() then gets the
old 0-7 mask from user_xcpus() and sets PERR_NOCPUS even though the new
mask leaves CPUs for the parent.
Move the exclusive_cpus update before partition_cpus_change() so that
the partition update sees the new mask.
Fixes: 46c521bac592 ("cgroup/cpuset: Enable invalid to valid local partition transition")
Signed-off-by: Guopeng Zhang <zhangguopeng@kylinos.cn>
---
kernel/cgroup/cpuset.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index de7553459adc..e96bc66ffa07 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -2546,10 +2546,14 @@ static int update_exclusive_cpumask(struct cpuset *cs, struct cpuset *trialcs,
return -ENOMEM;
trialcs->prs_err = PERR_NONE;
- partition_cpus_change(cs, trialcs, &tmp);
spin_lock_irq(&callback_lock);
cpumask_copy(cs->exclusive_cpus, trialcs->exclusive_cpus);
+ spin_unlock_irq(&callback_lock);
+
+ partition_cpus_change(cs, trialcs, &tmp);
+
+ spin_lock_irq(&callback_lock);
cpumask_copy(cs->effective_xcpus, trialcs->effective_xcpus);
if ((old_prs > 0) && !is_partition_valid(cs))
reset_partition_data(cs);
--
2.43.0
prev parent reply other threads:[~2026-10-10 8:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-10 7:59 [PATCH 0/2] cgroup/cpuset: Fix partition updates using stale CPU masks Guopeng Zhang
2026-10-10 7:59 ` [PATCH 1/2] cgroup/cpuset: Fix cpuset.cpus update in a remote partition Guopeng Zhang
2026-10-10 7:59 ` Guopeng Zhang [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=20261010075947.333549-3-guopeng.zhang@linux.dev \
--to=guopeng.zhang@linux.dev \
--cc=cgroups@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=longman@redhat.com \
--cc=mkoutny@suse.com \
--cc=ridong.chen@linux.dev \
--cc=tj@kernel.org \
--cc=zhangguopeng@kylinos.cn \
/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
all inboxes | Powered by JetHome®