From: Willy Tarreau Date: Tue, 11 Jul 2023 16:33:42 +0000 (+0200) Subject: MINOR: cpu-topo: try to detect offline cpus at boot X-Git-Tag: v3.2-dev8~83 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=12f3a2bbb75869426ce150614acd0dd46d299369;p=thirdparty%2Fhaproxy.git MINOR: cpu-topo: try to detect offline cpus at boot 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. --- diff --git a/src/cpu_topo.c b/src/cpu_topo.c index 3b1d29b8d..8d47fd01f 100644 --- a/src/cpu_topo.c +++ b/src/cpu_topo.c @@ -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; }