get_cpu_freq: handle CPUs with variable frequency

If a CPU has variable frequency, then lscpu will list separate "CPU min
freq" and "CPU max freq" values. In this case, take the maximum.

Sponsored-by: TrueNAS
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Attila Fülöp <attila@fueloep.org>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Alexander Motin <alexander.motin@TrueNAS.com>
Signed-off-by: Rob Norris <rob.norris@truenas.com>
Closes #18232
This commit is contained in:
Rob Norris 2026-02-18 13:27:41 +11:00 committed by Brian Behlendorf
parent d06a1d9ac3
commit b291d9aa22

View File

@ -2896,7 +2896,7 @@ function is_mp
function get_cpu_freq
{
if is_linux; then
lscpu | awk '/CPU MHz/ { print $3 }'
lscpu | awk '/CPU( max)? MHz/ { print $NF }'
elif is_freebsd; then
sysctl -n hw.clockrate
else