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.
This commit is contained in:
Willy Tarreau 2023-07-11 18:33:42 +02:00
parent 44881e5abf
commit 12f3a2bbb7

View 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;
}