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/for-next v4 4/4] cgroup/cpuset: Eliminate some duplicated rebuild_sched_domains() calls
Date: Mon, 9 Feb 2026 15:47:58 -0500 [thread overview]
Message-ID: <8d140b06-4e90-4c58-90dd-61aa5d1cbd5c@redhat.com> (raw)
In-Reply-To: <da363ddb-c006-4ff8-a327-5ef75045d3fd@huaweicloud.com>
On 2/9/26 2:53 AM, Chen Ridong wrote:
>
> On 2026/2/7 4:37, Waiman Long wrote:
>> Now that we are going to defer any changes to the HK_TYPE_DOMAIN
>> housekeeping cpumasks to either task_work or workqueue
>> where rebuild_sched_domains() call will be issued. The current
>> rebuild_sched_domains_locked() call near the end of the cpuset critical
>> section can be removed in such cases.
>>
>> Currently, a boolean force_sd_rebuild flag is used to decide if
>> rebuild_sched_domains_locked() call needs to be invoked. To allow
>> deferral that like, we change it to a tri-state sd_rebuild enumaration
>> type.
>>
>> Signed-off-by: Waiman Long <longman@redhat.com>
>> ---
>> kernel/cgroup/cpuset.c | 20 ++++++++++++++------
>> 1 file changed, 14 insertions(+), 6 deletions(-)
>>
>> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
>> index d26c77a726b2..e224df321e34 100644
>> --- a/kernel/cgroup/cpuset.c
>> +++ b/kernel/cgroup/cpuset.c
>> @@ -173,7 +173,11 @@ static bool isolcpus_twork_queued; /* T */
>> * Note that update_relax_domain_level() in cpuset-v1.c can still call
>> * rebuild_sched_domains_locked() directly without using this flag.
>> */
>> -static bool force_sd_rebuild; /* RWCS */
>> +static enum {
>> + SD_NO_REBUILD = 0,
>> + SD_REBUILD,
>> + SD_DEFER_REBUILD,
>> +} sd_rebuild; /* RWCS */
>>
>> /*
>> * Partition root states:
>> @@ -990,7 +994,7 @@ void rebuild_sched_domains_locked(void)
>>
>> lockdep_assert_cpus_held();
>> lockdep_assert_cpuset_lock_held();
>> - force_sd_rebuild = false;
>> + sd_rebuild = SD_NO_REBUILD;
>>
>> /* Generate domain masks and attrs */
>> ndoms = generate_sched_domains(&doms, &attr);
>> @@ -1377,6 +1381,9 @@ static void update_isolation_cpumasks(void)
>> else
>> isolated_cpus_updating = false;
>>
> If isolated_hk_cpus is defined, I believe isolated_cpus_updating becomes redundant.
Note that they have different exclusion rules. Other than that, you are
right that "!cpumask_equal(isolated_hk_cpu, isolated_cpus)" should be
equivalent to isolated_cpus_updating. But because of the different
exclusion rules, there are restriction on where you can use one or the
other.
>
>> + /* Defer rebuild_sched_domains() to task_work or wq */
>> + sd_rebuild = SD_DEFER_REBUILD;
>> +
> There is a potential issue: we defer all domain rebuilds here, including those
> triggered by hotplug events which may change the isolation state.
>
> The problem is that functions like cpuset_cpu_active, which rely on the
> scheduler domains being up-to-date—will, also be delayed. Is that okay?
No, we are not deferring all domain rebuilds. We are just deferring
domain rebuilds that involves changes in the set of isolated CPUs.
Domains rebuild will still happen if there is no changes in the set of
isolated CPUs. I need to take a further to investigate if this is a
problem or not. Anyway s suggested in my reply to Federic, I am
considering to not changing isolated_cpus due to hotplug events. In that
case, this problem should be gone.
Cheers,
Longman
prev parent reply other threads:[~2026-02-09 20:48 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-06 20:37 [PATCH/for-next v4 0/4] cgroup/cpuset: Fix partition related locking issues Waiman Long
2026-02-06 20:37 ` [PATCH/for-next v4 1/4] cgroup/cpuset: Clarify exclusion rules for cpuset internal variables Waiman Long
2026-02-09 3:41 ` Chen Ridong
2026-02-09 19:58 ` Waiman Long
2026-02-06 20:37 ` [PATCH/for-next v4 2/4] cgroup/cpuset: Defer housekeeping_update() calls from CPU hotplug to workqueue Waiman Long
2026-02-06 22:28 ` Frederic Weisbecker
2026-02-08 2:00 ` Waiman Long
2026-02-10 15:46 ` Frederic Weisbecker
2026-02-10 18:53 ` Waiman Long
2026-02-09 6:57 ` Chen Ridong
2026-02-06 20:37 ` [PATCH/for-next v4 3/4] cgroup/cpuset: Call housekeeping_update() without holding cpus_read_lock Waiman Long
2026-02-09 7:12 ` Chen Ridong
2026-02-09 20:29 ` Waiman Long
2026-02-10 1:29 ` Chen Ridong
2026-02-10 14:01 ` Waiman Long
2026-02-09 7:23 ` Chen Ridong
2026-02-09 20:20 ` Waiman Long
2026-02-10 1:39 ` Chen Ridong
2026-02-10 14:39 ` Waiman Long
2026-02-06 20:37 ` [PATCH/for-next v4 4/4] cgroup/cpuset: Eliminate some duplicated rebuild_sched_domains() calls Waiman Long
2026-02-09 7:53 ` Chen Ridong
2026-02-09 20:47 ` Waiman Long [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=8d140b06-4e90-4c58-90dd-61aa5d1cbd5c@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