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

Yury Norov
2024-05-13T22:01:53Z

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

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

diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
index 99ea5986038c..eb9eb17b0efa 100644
--- a/kernel/sched/topology.c
+++ b/kernel/sched/topology.c
@@ -2360,7 +2360,7 @@ static bool topology_span_sane(struct sched_domain_topology_level *tl,
* breaks the linking done for an earlier span.
*/
for_each_cpu(i, cpu_map) {
- if (i == cpu)
+ if (i == cpu || tl->mask(cpu) == tl->mask(i))
continue;
/*
* We should 'and' all those masks with 'cpu_map' to exactly
--
2.40.1