Skip to content

Commit 1805c17

Browse files
Waiman-Longhtejun
authored andcommitted
cgroup/cpuset: Optimize isolated partition only generate_sched_domains() calls
If only isolated partitions are being created underneath the cgroup root, there will only be one sched domain with top_cpuset.effective_cpus. We can skip the unnecessary sched domains scanning code and save some cycles. Signed-off-by: Waiman Long <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
1 parent 018ee56 commit 1805c17

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

kernel/cgroup/cpuset.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -964,6 +964,7 @@ static int generate_sched_domains(cpumask_var_t **domains,
964964

965965
/* Special case for the 99% of systems with one, full, sched domain */
966966
if (root_load_balance && !top_cpuset.nr_subparts) {
967+
single_root_domain:
967968
ndoms = 1;
968969
doms = alloc_sched_domains(ndoms);
969970
if (!doms)
@@ -1022,6 +1023,13 @@ static int generate_sched_domains(cpumask_var_t **domains,
10221023
}
10231024
rcu_read_unlock();
10241025

1026+
/*
1027+
* If there are only isolated partitions underneath the cgroup root,
1028+
* we can optimize out unneeded sched domains scanning.
1029+
*/
1030+
if (root_load_balance && (csn == 1))
1031+
goto single_root_domain;
1032+
10251033
for (i = 0; i < csn; i++)
10261034
csa[i]->pn = i;
10271035
ndoms = csn;

0 commit comments

Comments
 (0)