]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: cpu-topo: try to detect offline cpus at boot
authorWilly Tarreau <w@1wt.eu>
Tue, 11 Jul 2023 16:33:42 +0000 (18:33 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 14 Mar 2025 17:30:30 +0000 (18:30 +0100)
When possible, the offline CPUs are detected at boot and their OFFLINE
flag is set in the ha_cpu_topo[] array. When the detection is not
possible (e.g. not linux, /sys not mounted etc), we just mark none of
them as being offline, as we don't want to infer wrong info that could
hinder automatic CPU placement detection. When valid, we take this
opportunity for refining cpu_topo_lastcpu so that we don't need to
manipulate CPUs beyond this value.

src/cpu_topo.c

index 3b1d29b8d4c7393d6c280075acafd0f5f1cfe9f8..8d47fd01f38d9ca6675d81521f4dd33afe43ff87 100644 (file)
@@ -88,6 +88,19 @@ int cpu_detect_usable(void)
                if (!ha_cpuset_isset(&boot_set, cpu))
                        ha_cpu_topo[cpu].st |= HA_CPU_F_EXCLUDED;
 
+       /* Update the list of currently offline CPUs. Normally it's a subset
+        * of the unbound ones, but we cannot infer anything if we don't have
+        * the info so we only update what we know.
+        */
+       if (ha_cpuset_detect_online(&boot_set)) {
+               for (cpu = 0; cpu < cpu_topo_maxcpus; cpu++) {
+                       if (!ha_cpuset_isset(&boot_set, cpu))
+                               ha_cpu_topo[cpu].st |= HA_CPU_F_OFFLINE;
+                       else
+                               cpu_topo_lastcpu = cpu;
+               }
+       }
+
        return 0;
 }