From: Waiman Long <longman@redhat.com>
To: Guopeng Zhang <guopeng.zhang@linux.dev>,
Tejun Heo <tj@kernel.org>, Ridong Chen <ridong.chen@linux.dev>
Cc: Johannes Weiner <hannes@cmpxchg.org>,
Michal Koutny <mkoutny@suse.com>, Shuah Khan <shuah@kernel.org>,
cgroups@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org,
Guopeng Zhang <zhangguopeng@kylinos.cn>
Subject: Re: [PATCH v2 2/3] cgroup/cpuset: Preserve boot-isolated CPUs on partition release
Date: Mon, 24 Aug 2026 10:17:29 -0400 [thread overview]
Message-ID: <c0b5bc99-c1e4-4cf1-bd51-f71cc391c03c@redhat.com> (raw)
In-Reply-To: <20260824020140.21130-3-guopeng.zhang@linux.dev>
On 8/23/26 10:01 PM, Guopeng Zhang wrote:
> From: Guopeng Zhang <zhangguopeng@kylinos.cn>
>
> isolated_cpus tracks CPUs isolated with isolcpus= as well as CPUs in
> isolated cpuset partitions. When an isolated partition is released,
> isolated_cpus_update() removes its whole CPU mask. This also clears CPUs
> which were already isolated at boot.
>
> This can be reproduced on a cgroup v2 system booted with
> isolcpus=domain,15:
>
> cd /sys/fs/cgroup
> echo +cpuset > cgroup.subtree_control
> mkdir cpuset-repro
> echo 15 > cpuset-repro/cpuset.cpus
> echo isolated > cpuset-repro/cpuset.cpus.partition
> echo member > cpuset-repro/cpuset.cpus.partition
> cat cpuset.cpus.isolated
>
> CPU 15 is absent before the change. It must remain in
> cpuset.cpus.isolated after the partition is released.
>
> Update isolated_cpus one CPU at a time and keep CPUs outside the
> boot-time domain housekeeping mask isolated.
>
> Fixes: c188f33c864e ("cgroup/cpuset: Account for boot time isolated CPUs")
> Signed-off-by: Guopeng Zhang <zhangguopeng@kylinos.cn>
> ---
> kernel/cgroup/cpuset.c | 39 +++++++++++++++++++++++++++++----------
> 1 file changed, 29 insertions(+), 10 deletions(-)
>
> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
> index d100634fa12b..2538faac9aba 100644
> --- a/kernel/cgroup/cpuset.c
> +++ b/kernel/cgroup/cpuset.c
> @@ -1259,6 +1259,28 @@ static void reset_partition_data(struct cpuset *cs)
> cpumask_copy(cs->effective_cpus, parent->effective_cpus);
> }
>
> +/* Return true if isolated_cpus changes. */
> +static bool isolated_cpu_update(int new_prs, int cpu)
> +{
> + lockdep_assert_held(&callback_lock);
> + lockdep_assert_held(&cpuset_mutex);
> +
> + if (new_prs == PRS_ISOLATED) {
> + if (cpumask_test_cpu(cpu, isolated_cpus))
> + return false;
> + cpumask_set_cpu(cpu, isolated_cpus);
> + return true;
> + }
> +
> + /* CPUs isolated at boot must remain isolated. */
> + if (!cpumask_test_cpu(cpu,
> + housekeeping_cpumask(HK_TYPE_DOMAIN_BOOT)) ||
> + !cpumask_test_cpu(cpu, isolated_cpus))
> + return false;
> + cpumask_clear_cpu(cpu, isolated_cpus);
> + return true;
> +}
> +
> /*
> * isolated_cpus_update - Update the isolated_cpus mask
> * @old_prs: old partition_root_state
> @@ -1267,19 +1289,16 @@ static void reset_partition_data(struct cpuset *cs)
> */
> static void isolated_cpus_update(int old_prs, int new_prs, struct cpumask *xcpus)
> {
> + bool updated = false;
> + int cpu;
> +
> WARN_ON_ONCE(old_prs == new_prs);
> lockdep_assert_held(&callback_lock);
> lockdep_assert_held(&cpuset_mutex);
> - if (new_prs == PRS_ISOLATED) {
> - if (cpumask_subset(xcpus, isolated_cpus))
> - return;
> - cpumask_or(isolated_cpus, isolated_cpus, xcpus);
> - } else {
> - if (!cpumask_intersects(xcpus, isolated_cpus))
> - return;
> - cpumask_andnot(isolated_cpus, isolated_cpus, xcpus);
> - }
> - update_housekeeping = true;
> + for_each_cpu(cpu, xcpus)
> + updated |= isolated_cpu_update(new_prs, cpu);
> + if (updated)
> + update_housekeeping = true;
> }
>
> /*
The code is technically correct. However, handling it one CPU at a time
is less efficient from my point of view. It can be handled more
efficiently from the cpumask level. I do notice that the new
isolated_cpu_update() helper is being used in a later patch in your
larger series. Maybe that is the reason why you do it this way.
I am OK with this change.
Acked-by: Waiman Long <longman@redhat.com>
next prev parent reply other threads:[~2026-08-24 14:17 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-24 2:01 [PATCH v2 0/3] cgroup/cpuset: Preserve boot-isolated CPUs on partition release Guopeng Zhang
2026-08-24 2:01 ` [PATCH v2 1/3] selftests/cgroup: Drop invalid boot isolation comparison Guopeng Zhang
2026-08-24 3:23 ` Waiman Long
2026-08-24 2:01 ` [PATCH v2 2/3] cgroup/cpuset: Preserve boot-isolated CPUs on partition release Guopeng Zhang
2026-08-24 14:17 ` Waiman Long [this message]
2026-08-24 2:01 ` [PATCH v2 3/3] selftests/cgroup: Add test for preserving boot-isolated CPUs Guopeng Zhang
2026-08-24 14:18 ` Waiman Long
2026-08-24 17:04 ` [PATCH v2 0/3] cgroup/cpuset: Preserve boot-isolated CPUs on partition release Tejun Heo
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=c0b5bc99-c1e4-4cf1-bd51-f71cc391c03c@redhat.com \
--to=longman@redhat.com \
--cc=cgroups@vger.kernel.org \
--cc=guopeng.zhang@linux.dev \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=mkoutny@suse.com \
--cc=ridong.chen@linux.dev \
--cc=shuah@kernel.org \
--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