Skip to content

Commit 3ae0b77

Browse files
Waiman-Longhtejun
authored andcommitted
cgroup/cpuset: Allow suppression of sched domain rebuild in update_cpumasks_hier()
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 <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
1 parent 99fe36b commit 3ae0b77

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

kernel/cgroup/cpuset.c

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1590,6 +1590,12 @@ static int update_parent_subparts_cpumask(struct cpuset *cs, int cmd,
15901590
return 0;
15911591
}
15921592

1593+
/*
1594+
* update_cpumasks_hier() flags
1595+
*/
1596+
#define HIER_CHECKALL 0x01 /* Check all cpusets with no skipping */
1597+
#define HIER_NO_SD_REBUILD 0x02 /* Don't rebuild sched domains */
1598+
15931599
/*
15941600
* update_cpumasks_hier - Update effective cpumasks and tasks in the subtree
15951601
* @cs: the cpuset to consider
@@ -1604,7 +1610,7 @@ static int update_parent_subparts_cpumask(struct cpuset *cs, int cmd,
16041610
* Called with cpuset_mutex held
16051611
*/
16061612
static void update_cpumasks_hier(struct cpuset *cs, struct tmpmasks *tmp,
1607-
bool force)
1613+
int flags)
16081614
{
16091615
struct cpuset *cp;
16101616
struct cgroup_subsys_state *pos_css;
@@ -1644,10 +1650,10 @@ static void update_cpumasks_hier(struct cpuset *cs, struct tmpmasks *tmp,
16441650
* Skip the whole subtree if
16451651
* 1) the cpumask remains the same,
16461652
* 2) has no partition root state,
1647-
* 3) force flag not set, and
1653+
* 3) HIER_CHECKALL flag not set, and
16481654
* 4) for v2 load balance state same as its parent.
16491655
*/
1650-
if (!cp->partition_root_state && !force &&
1656+
if (!cp->partition_root_state && !(flags & HIER_CHECKALL) &&
16511657
cpumask_equal(tmp->new_cpus, cp->effective_cpus) &&
16521658
(!cgroup_subsys_on_dfl(cpuset_cgrp_subsys) ||
16531659
(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,
17641770
}
17651771
rcu_read_unlock();
17661772

1767-
if (need_rebuild_sched_domains)
1773+
if (need_rebuild_sched_domains && !(flags & HIER_NO_SD_REBUILD))
17681774
rebuild_sched_domains_locked();
17691775
}
17701776

@@ -1788,7 +1794,9 @@ static void update_sibling_cpumasks(struct cpuset *parent, struct cpuset *cs,
17881794
* to use the right effective_cpus value.
17891795
*
17901796
* The update_cpumasks_hier() function may sleep. So we have to
1791-
* release the RCU read lock before calling it.
1797+
* release the RCU read lock before calling it. HIER_NO_SD_REBUILD
1798+
* flag is used to suppress rebuild of sched domains as the callers
1799+
* will take care of that.
17921800
*/
17931801
rcu_read_lock();
17941802
cpuset_for_each_child(sibling, pos_css, parent) {
@@ -1800,7 +1808,7 @@ static void update_sibling_cpumasks(struct cpuset *parent, struct cpuset *cs,
18001808
continue;
18011809

18021810
rcu_read_unlock();
1803-
update_cpumasks_hier(sibling, tmp, false);
1811+
update_cpumasks_hier(sibling, tmp, HIER_NO_SD_REBUILD);
18041812
rcu_read_lock();
18051813
css_put(&sibling->css);
18061814
}
@@ -1913,7 +1921,7 @@ static int update_cpumask(struct cpuset *cs, struct cpuset *trialcs,
19131921
spin_unlock_irq(&callback_lock);
19141922

19151923
/* effective_cpus will be updated here */
1916-
update_cpumasks_hier(cs, &tmp, false);
1924+
update_cpumasks_hier(cs, &tmp, 0);
19171925

19181926
if (cs->partition_root_state) {
19191927
struct cpuset *parent = parent_cs(cs);
@@ -2382,7 +2390,7 @@ static int update_prstate(struct cpuset *cs, int new_prs)
23822390
* Force update if switching back to member.
23832391
*/
23842392
if (!list_empty(&cs->css.children))
2385-
update_cpumasks_hier(cs, &tmpmask, !new_prs);
2393+
update_cpumasks_hier(cs, &tmpmask, !new_prs ? HIER_CHECKALL : 0);
23862394

23872395
/* Update sched domains and load balance flag */
23882396
update_partition_sd_lb(cs, old_prs);

0 commit comments

Comments
 (0)