From 8542c79f9daa925619215325e0fca52c80d9a419 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Mon, 6 Jan 2025 19:38:45 +0100 Subject: [PATCH] MINOR: cpu-topo: skip CPU detection when /sys/.../cpu does not exist There's no point scanning all entries when /cpu doesn't exist in the first place. Let's check once for it and skip the loop in this case. --- src/cpu_topo.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/cpu_topo.c b/src/cpu_topo.c index d59c0c888..44814409e 100644 --- a/src/cpu_topo.c +++ b/src/cpu_topo.c @@ -259,6 +259,10 @@ int cpu_detect_topology(void) * thread_set_id, cluster_id, l1/l2/l3 id, etc. We don't revisit entries * already filled from the list provided by another CPU. */ + + if (!is_dir_present(NUMA_DETECT_SYSTEM_SYSFS_PATH "/cpu")) + goto skip_cpu; + for (cpu = 0; cpu <= cpu_topo_lastcpu; cpu++) { struct hap_cpuset cpus_list; int next_level = 1; // assume L1 if unknown @@ -442,6 +446,7 @@ int cpu_detect_topology(void) } } + skip_cpu: /* Now locate NUMA node IDs if any */ dir = opendir(NUMA_DETECT_SYSTEM_SYSFS_PATH "/node");