Skip to content

Commit

Permalink
cgroup/cpuset: Optimize isolated partition only generate_sched_domain…
Browse files Browse the repository at this point in the history
…s() 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]>
  • Loading branch information
Waiman-Long authored and htejun committed Jun 3, 2024
1 parent 018ee56 commit 1805c17
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions kernel/cgroup/cpuset.c
Original file line number Diff line number Diff line change
Expand Up @@ -964,6 +964,7 @@ static int generate_sched_domains(cpumask_var_t **domains,

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

/*
* If there are only isolated partitions underneath the cgroup root,
* we can optimize out unneeded sched domains scanning.
*/
if (root_load_balance && (csn == 1))
goto single_root_domain;

for (i = 0; i < csn; i++)
csa[i]->pn = i;
ndoms = csn;
Expand Down

0 comments on commit 1805c17

Please sign in to comment.