]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MINOR: cpu-topo: count cores not cpus to distinguish core types
authorWilly Tarreau <w@1wt.eu>
Mon, 2 Feb 2026 16:55:57 +0000 (17:55 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 4 Feb 2026 07:49:18 +0000 (08:49 +0100)
commitcddeea58cdd141ab9855e5228b282d30500c42e7
tree314d201adb3208ed25fdbd857513a49048039ae4
parent3674afe8a085613213fcb1e38dc203fa4f7161d5
BUG/MINOR: cpu-topo: count cores not cpus to distinguish core types

The per-cpu capacity of a cluster was taken into account since 3.2 with
commit 6c88e27cf4 ("MEDIUM: cpu-topo: change "performance" to consider
per-core capacity").

In cpu_policy_performance() and cpu_policy_efficiency(), we're trying
to figure which cores have more capacity than others by comparing their
cluster's average capacity. However, contrary to what the comment says,
we're not averaging per core but per cpu, which makes a difference for
CPUs mixing SMT with non-SMT cores on the same SoC, such as intel's 14th
gen CPUs. Indeed, on a machine where cpufreq is not enabled, all CPUs
can be reported with a capacity of 1024, resulting in a big cluster of
16*1024, and 4 small clusters of 4*1024 each, giving an average of 1024
per CPU, making it impossible to distinguish one from the other. In this
situation, both "cpu-policy performance" and "cpu-policy efficiency"
enable all cores.

But this is wrong, what needs to be taken into account in the divide is
the number of *cores*, not *cpus*, that allows to distinguish big from
little clusters. This was not noticeable on the ARM machines the commit
above aimed at fixing because there, the number of CPUs equals the number
of cores. And on an x86 machine with cpu_freq enabled, the frequencies
continue to help spotting which ones are big/little.

By using nb_cores instead of nb_cpus in the comparison and in the avg_capa
compare function, it properly works again on x86 without affecting other
machines with 1 CPU per core.

This can be backported to 3.2.
src/cpu_topo.c