[PATCH 2/2] sched/topology: optimize topology_span_sane()

From: Yury Norov
Date: Fri Aug 02 2024 - 13:58:32 EST


The function may call cpumask_equal with tl->mask(cpu) == tl->mask(i),
even when cpu != i. In such case, cpumask_equal() would always return
true, and we can proceed to the next iteration immediately.

Signed-off-by: Yury Norov <yury.norov@xxxxxxxxx>
---
kernel/sched/topology.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
index 754ad5fa3c99..571759606954 100644
--- a/kernel/sched/topology.c
+++ b/kernel/sched/topology.c
@@ -2368,6 +2368,8 @@ static bool topology_span_sane(struct sched_domain_topology_level *tl,
*/
for_each_cpu_from(i, cpu_map) {
mi = tl->mask(i);
+ if (mi == mc)
+ continue;

/*
* We should 'and' all those masks with 'cpu_map' to exactly
--
2.43.0