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.
This commit is contained in:
Willy Tarreau 2025-01-06 19:38:45 +01:00
parent c5ddf4a5b2
commit 8542c79f9d

View File

@ -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");