]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: cpu-topo: skip CPU detection when /sys/.../cpu does not exist
authorWilly Tarreau <w@1wt.eu>
Mon, 6 Jan 2025 18:38:45 +0000 (19:38 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 14 Mar 2025 17:30:30 +0000 (18:30 +0100)
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

index d59c0c888814685cdc87ef93f0a6a41435ec044f..44814409ef36e217bfed28b31141d2e10da4537c 100644 (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");