From: Waiman Long <longman@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, Waiman Long <longman@redhat.com>
Subject: [PATCH v5 6/6] cgroup/cpuset: Eliminate some duplicated rebuild_sched_domains() calls
Date: Thu, 12 Feb 2026 11:46:40 -0500 [thread overview]
Message-ID: <20260212164640.2408295-7-longman@redhat.com> (raw)
In-Reply-To: <20260212164640.2408295-1-longman@redhat.com>
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 c6a97956a991..426949363ca7 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -178,7 +178,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:
@@ -1023,7 +1027,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);
@@ -1408,6 +1412,9 @@ static void update_isolation_cpumasks(void)
else
isolated_cpus_updating = false;
+ /* Defer rebuild_sched_domains() to task_work or wq */
+ sd_rebuild = SD_DEFER_REBUILD;
+
/*
* CPU hotplug shouldn't set isolated_cpus_updating.
*
@@ -3053,7 +3060,7 @@ static int update_prstate(struct cpuset *cs, int new_prs)
update_partition_sd_lb(cs, old_prs);
notify_partition_change(cs, old_prs);
- if (force_sd_rebuild)
+ if (sd_rebuild == SD_REBUILD)
rebuild_sched_domains_locked();
free_tmpmasks(&tmpmask);
return 0;
@@ -3330,7 +3337,7 @@ ssize_t cpuset_write_resmask(struct kernfs_open_file *of,
}
free_cpuset(trialcs);
- if (force_sd_rebuild)
+ if (sd_rebuild == SD_REBUILD)
rebuild_sched_domains_locked();
out_unlock:
cpuset_full_unlock();
@@ -3815,7 +3822,8 @@ hotplug_update_tasks(struct cpuset *cs,
void cpuset_force_rebuild(void)
{
- force_sd_rebuild = true;
+ if (!sd_rebuild)
+ sd_rebuild = SD_REBUILD;
}
/**
@@ -4025,7 +4033,7 @@ static void cpuset_handle_hotplug(void)
}
/* rebuild sched domains if necessary */
- if (force_sd_rebuild)
+ if (sd_rebuild == SD_REBUILD)
rebuild_sched_domains_cpuslocked();
free_tmpmasks(ptmp);
--
2.52.0
prev parent reply other threads:[~2026-02-12 16:48 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
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 ` 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=20260212164640.2408295-7-longman@redhat.com \
--to=longman@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