Skip to contentSkip to conversation

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

PATCH-cgroup Applied Waiman Long 2 participants 2 messages Jun 3, 2024

Subsystems (2)
lore
Share & tools
lore

Waiman Long

author maintainer
#0 lore raw

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.

---
 kernel/cgroup/cpuset.c | 8 ++++++++
 1 file changed, 8 insertions(+)
kernel/cgroup/cpuset.c +8 -0
index 315f8cbd6d35..f9b97f65e204 100644
@@ -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;
Signature · 1 line
2.39.3
maintainer Applied
#1 lore raw
Quoted 5 lines · Waiman Long

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.

Applied to cgroup/for-6.11.

Thanks.

Signature · 1 line
tejun