cpupower: Fix checks for CPU existence
authorBen Hutchings <ben@decadent.org.uk>
Thu, 3 Nov 2016 21:25:26 +0000 (15:25 -0600)
committerSalvatore Bonaccorso <carnil@debian.org>
Fri, 25 Apr 2025 19:51:43 +0000 (21:51 +0200)
commit9204fbce67abd4a0b18d46870ff5f06f8097fb86
tree434126e51b0b61174973a56950be24a40afcbd6e
parent1b8e8eb8986a4d9127692c31e26d8da52069c33a
cpupower: Fix checks for CPU existence

Forwarded: https://marc.info/?l=linux-pm&m=149248268214265

Calls to cpufreq_cpu_exists(cpu) were converted to
cpupower_is_cpu_online(cpu) when libcpupower was introduced and the
former function was deleted.  However, cpupower_is_cpu_online() does
not distinguish physically absent and offline CPUs, and does not set
errno.

cpufreq-set has already been fixed (commit c25badc9ceb6).

In cpufreq-bench, which prints an error message for offline CPUs,
properly distinguish and report the zero and negative cases.

Fixes: ac5a181d065d ("cpupower: Add cpuidle parts into library")
Fixes: 53d1cd6b125f ("cpupowerutils: bench - Fix cpu online check")
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
[carnil: Update/Refresh patch for 4.14.17: The issue with the
incorrect check has been fixed with upstream commit 53d1cd6b125f.
Keep in the patch the distinction and report for the zero and
negative cases.]

Gbp-Pq: Topic bugfix/all
Gbp-Pq: Name cpupower-fix-checks-for-cpu-existence.patch
tools/power/cpupower/bench/system.c