Hi,

Here a little patch proposal for cpu topology dump part when we try
to figure out if we are in a SMT context.

Regards.
From 2cf529895815b6d78aeb771d5d77e1651a4d45b5 Mon Sep 17 00:00:00 2001
From: David Carlier <devne...@gmail.com>
Date: Wed, 2 Apr 2025 07:00:44 +0100
Subject: [PATCH] MINOR: cpu-topo: cpu_dump_topology() SMT info check little
 optimisation

Once we stumble across the first cpu having the criteria, we exit
earlier from the loop.
---
 src/cpu_topo.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/cpu_topo.c b/src/cpu_topo.c
index 0d3354a6c..8bf51dd1c 100644
--- a/src/cpu_topo.c
+++ b/src/cpu_topo.c
@@ -219,9 +219,12 @@ void cpu_dump_topology(const struct ha_cpu_topo *topo)
 	int cpu, lvl;
 	int grp, thr;
 
-	for (cpu = 0; cpu <= cpu_topo_lastcpu; cpu++)
-		if (ha_cpu_topo[cpu].th_cnt > 1)
+	for (cpu = 0; cpu <= cpu_topo_lastcpu; cpu++) {
+		if (ha_cpu_topo[cpu].th_cnt > 1) {
 			has_smt = 1;
+			break;
+		}
+	}
 
 	for (cpu = 0; cpu <= cpu_topo_lastcpu; cpu++) {
 		if (ha_cpu_topo[cpu].st & HA_CPU_F_OFFLINE)
-- 
2.49.0

Reply via email to