Commit 8799cb6d authored by Waiman Long's avatar Waiman Long Committed by Chen Ridong
Browse files

cgroup/cpuset: Optimize isolated partition only generate_sched_domains() calls

mainline inclusion
from mainline-v6.11-rc1
commit 1805c1729f52edaa021288473b09f9c7f74fb1ca
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IAOPW2

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=1805c1729f52edaa021288473b09f9c7f74fb1ca



----------------------------------------------------------------------

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: default avatarWaiman Long <longman@redhat.com>
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Signed-off-by: default avatarChen Ridong <chenridong@huawei.com>
parent 392f26f4
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -1121,6 +1121,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)
@@ -1179,6 +1180,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;