]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
cgroup/cpuset: Optimize isolated partition only generate_sched_domains() calls
authorWaiman Long <longman@redhat.com>
Mon, 3 Jun 2024 19:38:22 +0000 (15:38 -0400)
committerTejun Heo <tj@kernel.org>
Mon, 3 Jun 2024 19:47:11 +0000 (09:47 -1000)
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 <longman@redhat.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
kernel/cgroup/cpuset.c

index 315f8cbd6d35a0e24ca211aafecb20260fc69f23..f9b97f65e204b4fd31eda76fcfca82910abae8a2 100644 (file)
@@ -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)
@@ -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;