public inbox for cgroups@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH-cgroup] cgroup/cpuset: Optimize isolated partition only generate_sched_domains() calls
@ 2024-06-03 19:38 Waiman Long
  2024-06-03 19:48 ` Tejun Heo
  0 siblings, 1 reply; 2+ messages in thread
From: Waiman Long @ 2024-06-03 19:38 UTC (permalink / raw)
  To: Tejun Heo, Zefan Li, Johannes Weiner
  Cc: cgroups, linux-kernel, Xavier, 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.

Signed-off-by: Waiman Long <longman@redhat.com>
---
 kernel/cgroup/cpuset.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index 315f8cbd6d35..f9b97f65e204 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -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;
-- 
2.39.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH-cgroup] cgroup/cpuset: Optimize isolated partition only generate_sched_domains() calls
  2024-06-03 19:38 [PATCH-cgroup] cgroup/cpuset: Optimize isolated partition only generate_sched_domains() calls Waiman Long
@ 2024-06-03 19:48 ` Tejun Heo
  0 siblings, 0 replies; 2+ messages in thread
From: Tejun Heo @ 2024-06-03 19:48 UTC (permalink / raw)
  To: Waiman Long; +Cc: Zefan Li, Johannes Weiner, cgroups, linux-kernel, Xavier

On Mon, Jun 03, 2024 at 03:38:22PM -0400, Waiman Long wrote:
> 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>

Applied to cgroup/for-6.11.

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-06-03 19:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-03 19:38 [PATCH-cgroup] cgroup/cpuset: Optimize isolated partition only generate_sched_domains() calls Waiman Long
2024-06-03 19:48 ` Tejun Heo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox