From: Waiman Long <llong@redhat.com>
To: "Chen Ridong" <chenridong@huaweicloud.com>,
"Tejun Heo" <tj@kernel.org>,
"Johannes Weiner" <hannes@cmpxchg.org>,
"Michal Koutný" <mkoutny@suse.com>,
"Ingo Molnar" <mingo@redhat.com>,
"Peter Zijlstra" <peterz@infradead.org>,
"Juri Lelli" <juri.lelli@redhat.com>,
"Vincent Guittot" <vincent.guittot@linaro.org>,
"Steven Rostedt" <rostedt@goodmis.org>,
"Ben Segall" <bsegall@google.com>, "Mel Gorman" <mgorman@suse.de>,
"Valentin Schneider" <vschneid@redhat.com>,
"Anna-Maria Behnsen" <anna-maria@linutronix.de>,
"Frederic Weisbecker" <frederic@kernel.org>,
"Thomas Gleixner" <tglx@linutronix.de>,
"Shuah Khan" <shuah@kernel.org>
Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org
Subject: Re: [PATCH v5 4/6] cgroup/cpuset: Don't update isolated_cpus from CPU hotplug
Date: Fri, 13 Feb 2026 10:28:09 -0500 [thread overview]
Message-ID: <dcb4debf-e166-491e-8f7b-5500e5e8a39c@redhat.com> (raw)
In-Reply-To: <de1cf3d0-8922-4740-9e4f-501cc38c70b0@huaweicloud.com>
On 2/12/26 10:28 PM, Chen Ridong wrote:
>
> On 2026/2/13 0:46, Waiman Long wrote:
>> As any change to isolated_cpus is going to be propagated to the
>> HK_TYPE_DOMAIN housekeeping cpumask, it can be problematic if
>> housekeeping cpumasks are directly being modified from the CPU hotplug
>> code path. This is especially the case if we are going to enable dynamic
>> update to the nohz_full housekeeping cpumask (HK_TYPE_KERNEL_NOISE)
>> in the near future with the help of CPU hotplug.
>>
>> Avoid these potential problems by changing the cpuset code to not
>> updating isolated_cpus when calling from CPU hotplug. A new special
>> PRS_INVALID_ISOLCPUS is added to indicate the current cpuset is an
>> invalid partition but its effective_xcpus are still in isolated_cpus.
>> This special state will be set if an isolated partition becomes invalid
>> due to the shutdown of the last active CPU in that partition. We also
>> need to keep the effective_xcpus even if exclusive_cpus isn't set.
>>
>> When changes are made to "cpuset.cpus", "cpuset.cpus.exclusive" or
>> "cpuset.cpus.partition" of a PRS_INVALID_ISOLCPUS cpuset, its state
>> will be reset back to PRS_INVALID_ISOLATED and its effective_xcpus will
>> be removed from isolated_cpus before proceeding.
>>
>> As CPU hotplug will no longer update isolated_cpus, some of the test
>> cases in test_cpuset_prs.h will have to be updated to match the new
>> expected results. Some new test cases are also added to confirm that
>> "cpuset.cpus.isolated" and HK_TYPE_DOMAIN housekeeping cpumask will
>> both be updated.
>>
>> Signed-off-by: Waiman Long <longman@redhat.com>
>> ---
>> kernel/cgroup/cpuset.c | 85 ++++++++++++++++---
>> .../selftests/cgroup/test_cpuset_prs.sh | 21 +++--
>> 2 files changed, 87 insertions(+), 19 deletions(-)
>>
>> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
>> index c792380f9b60..48b7f275085b 100644
>> --- a/kernel/cgroup/cpuset.c
>> +++ b/kernel/cgroup/cpuset.c
>> @@ -159,6 +159,8 @@ static bool force_sd_rebuild; /* RWCS */
>> * 2 - partition root without load balancing (isolated)
>> * -1 - invalid partition root
>> * -2 - invalid isolated partition root
>> + * -3 - invalid isolated partition root but with effective xcpus still
>> + * in isolated_cpus (set from CPU hotplug side)
>> *
>> * There are 2 types of partitions - local or remote. Local partitions are
>> * those whose parents are partition root themselves. Setting of
>> @@ -187,6 +189,7 @@ static bool force_sd_rebuild; /* RWCS */
>> #define PRS_ISOLATED 2
>> #define PRS_INVALID_ROOT -1
>> #define PRS_INVALID_ISOLATED -2
>> +#define PRS_INVALID_ISOLCPUS -3 /* Effective xcpus still in isolated_cpus */
>>
>> /*
>> * Temporary cpumasks for working with partitions that are passed among
>> @@ -382,6 +385,30 @@ static inline bool is_in_v2_mode(void)
>> (cpuset_cgrp_subsys.root->flags & CGRP_ROOT_CPUSET_V2_MODE);
>> }
>>
>> +/*
>> + * If the given cpuset has a partition state of PRS_INVALID_ISOLCPUS,
>> + * remove its effective_xcpus from isolated_cpus and reset its state to
>> + * PRS_INVALID_ISOLATED. Also clear effective_xcpus if exclusive_cpus is
>> + * empty.
>> + */
>> +static void fix_invalid_isolcpus(struct cpuset *cs, struct cpuset *trialcs)
>> +{
>> + if (likely(cs->partition_root_state != PRS_INVALID_ISOLCPUS))
>> + return;
>> + WARN_ON_ONCE(cpumask_empty(cs->effective_xcpus));
>> + spin_lock_irq(&callback_lock);
>> + cpumask_andnot(isolated_cpus, isolated_cpus, cs->effective_xcpus);
>> + if (cpumask_empty(cs->exclusive_cpus))
>> + cpumask_clear(cs->effective_xcpus);
>> + cs->partition_root_state = PRS_INVALID_ISOLATED;
>> + spin_unlock_irq(&callback_lock);
>> + isolated_cpus_updating = true;
>> + if (trialcs) {
>> + trialcs->partition_root_state = PRS_INVALID_ISOLATED;
>> + cpumask_copy(trialcs->effective_xcpus, cs->effective_xcpus);
>> + }
>> +}
> When fix_invalid_isolcpus is called from changing cpus/exclusive cpus, should we
> copy cs->effective_xcpus to trialcs->effective_xcpus?
>
> I tested as follow steps(using the whole series):
>
> # cd /sys/fs/cgroup/
> # mkdir test
> # echo 1 > cpuset.cpus.
> # cd test/
> # echo 1 > cpuset.cpus.exclusive
> # echo $$ > cgroup.procs
> # echo isolated > cpuset.cpus.partition
> # cat cpuset.cpus.partition
> isolated
> # echo 0 > /sys/devices/system/cpu/cpu1/online
> # cat cpuset.cpus.partition
> isolated invalid
> # echo 2 > cpuset.cpus.exclusive
> # cat cpuset.cpus.partition
> isolated invalid (Parent unable to distribute cpu downstream)
>
> After changing cpuset.cpus.exclusive to 2, the test cpuset should
> become valid again, but it remains invalid.
Right, changes to trialcs->effective_xcpus is unnecessary() as
compute_trialcs_excpus() will be called before fix_invalid_isolcpus() is
invoked. Will fix that in the next version.
Thanks,
Longman
next prev parent reply other threads:[~2026-02-13 15:28 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-12 16:46 [PATCH v5 0/6] cgroup/cpuset: Fix partition related locking issues Waiman Long
2026-02-12 16:46 ` [PATCH v5 1/6] cgroup/cpuset: Fix incorrect change to effective_xcpus in partition_xcpus_del() Waiman Long
2026-02-13 0:52 ` Chen Ridong
2026-02-12 16:46 ` [PATCH v5 2/6] cgroup/cpuset: Clarify exclusion rules for cpuset internal variables Waiman Long
2026-02-13 1:35 ` Chen Ridong
2026-02-12 16:46 ` [PATCH v5 3/6] cgroup/cpuset: Set isolated_cpus_updating only if isolated_cpus is changed Waiman Long
2026-02-13 2:06 ` Chen Ridong
2026-02-12 16:46 ` [PATCH v5 4/6] cgroup/cpuset: Don't update isolated_cpus from CPU hotplug Waiman Long
2026-02-13 3:28 ` Chen Ridong
2026-02-13 15:28 ` Waiman Long [this message]
2026-02-13 6:56 ` Chen Ridong
2026-02-21 19:18 ` Waiman Long
2026-02-12 16:46 ` [PATCH v5 5/6] cgroup/cpuset: Call housekeeping_update() without holding cpus_read_lock Waiman Long
2026-02-13 7:47 ` Chen Ridong
2026-02-21 19:20 ` Waiman Long
2026-02-12 16:46 ` [PATCH v5 6/6] cgroup/cpuset: Eliminate some duplicated rebuild_sched_domains() calls Waiman Long
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=dcb4debf-e166-491e-8f7b-5500e5e8a39c@redhat.com \
--to=llong@redhat.com \
--cc=anna-maria@linutronix.de \
--cc=bsegall@google.com \
--cc=cgroups@vger.kernel.org \
--cc=chenridong@huaweicloud.com \
--cc=frederic@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=mkoutny@suse.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=shuah@kernel.org \
--cc=tglx@linutronix.de \
--cc=tj@kernel.org \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
/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