From: Waiman Long <longman-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Zefan Li <lizefan.x-EC8Uxl6Npydl57MIdRCFDg@public.gmane.org>,
Johannes Weiner <hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org>,
Jonathan Corbet <corbet-T1hC0tSOHrs@public.gmane.org>,
Shuah Khan <shuah-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-doc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kselftest-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Juri Lelli <juri.lelli-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
Valentin Schneider
<vschneid-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
Frederic Weisbecker
<frederic-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Mrunal Patel <mpatel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
Ryan Phillips <rphillips-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
Brent Rowsell <browsell-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
Peter Hunt <pehunt-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
Phil Auld <pauld-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
Waiman Long <longman-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Subject: [PATCH v4 4/9] cgroup/cpuset: Allow suppression of sched domain rebuild in update_cpumasks_hier()
Date: Tue, 27 Jun 2023 10:35:03 -0400 [thread overview]
Message-ID: <20230627143508.1576882-5-longman@redhat.com> (raw)
In-Reply-To: <20230627143508.1576882-1-longman-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
A single partition setup and tear-down operation can lead to
multiple rebuild_sched_domains_locked() calls which is a waste of
effort. This can partly be mitigated by adding a flag to suppress the
rebuild_sched_domains_locked() call in update_cpumasks_hier(). Since
a Boolean flag has already been passed as the 3rd argument to
update_cpumasks_hier(), we can extend that to a full flag word.
The sched domain rebuild suppression is now enabled in
update_sibling_cpumasks() as all it callers will do the sched domain
rebuild after its return later on anyway.
Signed-off-by: Waiman Long <longman-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
kernel/cgroup/cpuset.c | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index b8ccc1be7bde..64f9e305b3ab 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -1590,6 +1590,12 @@ static int update_parent_subparts_cpumask(struct cpuset *cs, int cmd,
return 0;
}
+/*
+ * update_cpumasks_hier() flags
+ */
+#define HIER_CHECKALL 0x01 /* Check all cpusets with no skipping */
+#define HIER_NO_SD_REBUILD 0x02 /* Don't rebuild sched domains */
+
/*
* update_cpumasks_hier - Update effective cpumasks and tasks in the subtree
* @cs: the cpuset to consider
@@ -1604,7 +1610,7 @@ static int update_parent_subparts_cpumask(struct cpuset *cs, int cmd,
* Called with cpuset_mutex held
*/
static void update_cpumasks_hier(struct cpuset *cs, struct tmpmasks *tmp,
- bool force)
+ int flags)
{
struct cpuset *cp;
struct cgroup_subsys_state *pos_css;
@@ -1644,10 +1650,10 @@ static void update_cpumasks_hier(struct cpuset *cs, struct tmpmasks *tmp,
* Skip the whole subtree if
* 1) the cpumask remains the same,
* 2) has no partition root state,
- * 3) force flag not set, and
+ * 3) HIER_CHECKALL flag not set, and
* 4) for v2 load balance state same as its parent.
*/
- if (!cp->partition_root_state && !force &&
+ if (!cp->partition_root_state && !(flags & HIER_CHECKALL) &&
cpumask_equal(tmp->new_cpus, cp->effective_cpus) &&
(!cgroup_subsys_on_dfl(cpuset_cgrp_subsys) ||
(is_sched_load_balance(parent) == is_sched_load_balance(cp)))) {
@@ -1764,7 +1770,7 @@ static void update_cpumasks_hier(struct cpuset *cs, struct tmpmasks *tmp,
}
rcu_read_unlock();
- if (need_rebuild_sched_domains)
+ if (need_rebuild_sched_domains && !(flags & HIER_NO_SD_REBUILD))
rebuild_sched_domains_locked();
}
@@ -1788,7 +1794,9 @@ static void update_sibling_cpumasks(struct cpuset *parent, struct cpuset *cs,
* to use the right effective_cpus value.
*
* The update_cpumasks_hier() function may sleep. So we have to
- * release the RCU read lock before calling it.
+ * release the RCU read lock before calling it. HIER_NO_SD_REBUILD
+ * flag is used to suppress rebuild of sched domains as the callers
+ * will take care of that.
*/
rcu_read_lock();
cpuset_for_each_child(sibling, pos_css, parent) {
@@ -1800,7 +1808,7 @@ static void update_sibling_cpumasks(struct cpuset *parent, struct cpuset *cs,
continue;
rcu_read_unlock();
- update_cpumasks_hier(sibling, tmp, false);
+ update_cpumasks_hier(sibling, tmp, HIER_NO_SD_REBUILD);
rcu_read_lock();
css_put(&sibling->css);
}
@@ -1913,7 +1921,7 @@ static int update_cpumask(struct cpuset *cs, struct cpuset *trialcs,
spin_unlock_irq(&callback_lock);
/* effective_cpus will be updated here */
- update_cpumasks_hier(cs, &tmp, false);
+ update_cpumasks_hier(cs, &tmp, 0);
if (cs->partition_root_state) {
struct cpuset *parent = parent_cs(cs);
@@ -2382,7 +2390,7 @@ static int update_prstate(struct cpuset *cs, int new_prs)
* Force update if switching back to member.
*/
if (!list_empty(&cs->css.children))
- update_cpumasks_hier(cs, &tmpmask, !new_prs);
+ update_cpumasks_hier(cs, &tmpmask, !new_prs ? HIER_CHECKALL : 0);
/* Update sched domains and load balance flag */
update_partition_sd_lb(cs, old_prs);
--
2.31.1
next prev parent reply other threads:[~2023-06-27 14:35 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-27 14:34 [PATCH v4 0/9] cgroup/cpuset: Support remote partitions Waiman Long
2023-06-27 14:35 ` [PATCH v4 1/9] cgroup/cpuset: Inherit parent's load balance state in v2 Waiman Long
2023-06-27 14:35 ` [PATCH v4 2/9] cgroup/cpuset: Extract out CS_CPU_EXCLUSIVE & CS_SCHED_LOAD_BALANCE handling Waiman Long
2023-06-27 14:35 ` [PATCH v4 3/9] cgroup/cpuset: Improve temporary cpumasks handling Waiman Long
2023-06-27 14:35 ` [PATCH v4 5/9] cgroup/cpuset: Add cpuset.cpus.exclusive for v2 Waiman Long
2023-06-27 14:35 ` [PATCH v4 6/9] cgroup/cpuset: Introduce remote partition Waiman Long
2023-06-27 14:35 ` [PATCH v4 7/9] cgroup/cpuset: Check partition conflict with housekeeping setup Waiman Long
[not found] ` <20230627143508.1576882-1-longman-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2023-06-27 14:35 ` Waiman Long [this message]
2023-07-10 21:01 ` [PATCH v4 4/9] cgroup/cpuset: Allow suppression of sched domain rebuild in update_cpumasks_hier() Tejun Heo
2023-06-27 14:35 ` [PATCH v4 8/9] cgroup/cpuset: Documentation update for partition Waiman Long
2023-07-10 21:30 ` Tejun Heo
[not found] ` <ZKx4ZJowRhRtjZxB-NiLfg/pYEd1N0TnZuCh8vA@public.gmane.org>
2023-07-11 0:21 ` Waiman Long
2023-07-11 0:42 ` Tejun Heo
2023-07-11 0:53 ` Waiman Long
[not found] ` <a429e60a-fc4f-60b0-3978-71596fed9542-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2023-07-11 1:07 ` Tejun Heo
2023-07-11 3:24 ` Waiman Long
2023-06-27 14:35 ` [PATCH v4 9/9] cgroup/cpuset: Extend test_cpuset_prs.sh to test remote partition Waiman Long
2023-07-10 21:08 ` [PATCH v4 0/9] cgroup/cpuset: Support remote partitions Tejun Heo
2023-07-11 0:33 ` Waiman Long
2023-07-11 1:00 ` Tejun Heo
2023-07-11 1:38 ` Waiman Long
2023-07-11 1:45 ` 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=20230627143508.1576882-5-longman@redhat.com \
--to=longman-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
--cc=browsell-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=corbet-T1hC0tSOHrs@public.gmane.org \
--cc=frederic-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org \
--cc=juri.lelli-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=linux-doc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kselftest-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=lizefan.x-EC8Uxl6Npydl57MIdRCFDg@public.gmane.org \
--cc=mpatel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=pauld-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=pehunt-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=rphillips-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=shuah-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=vschneid-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
/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