cpupower: Fix checks for CPU existence (Closes: #843071)

This commit is contained in:
Ben Hutchings 2016-11-03 16:11:35 -06:00
parent 18036575a7
commit d882885835
3 changed files with 74 additions and 0 deletions

1
debian/changelog vendored
View File

@ -119,6 +119,7 @@ linux (4.8.6-1) UNRELEASED; urgency=medium
- connector/cn_proc: Protect send_msg() with a local lock on RT
- drivers/zram: Don't disable preemption in zcomp_stream_get/put()
* HID: Enable HID_ALPS, HID_ASUS (Closes: #843085), HID_CMEDIA as modules
* cpupower: Fix checks for CPU existence (Closes: #843071)
-- Ben Hutchings <ben@decadent.org.uk> Wed, 02 Nov 2016 12:01:42 -0600

View File

@ -0,0 +1,72 @@
From: Ben Hutchings <ben@decadent.org.uk>
Date: Thu, 03 Nov 2016 15:25:26 -0600
Subject: cpupower: Fix checks for CPU existence
Bug: https://bugzilla.kernel.org/show_bug.cgi?id=135391
Bug-Debian: https://bugs.debian.org/843071
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()
returns 1 on success whereas cpufreq_cpu_exists() returned 0 on
success. It also does not distinguish physically absent and offline
CPUs, and does not set errno.
In cpufreq-set, test for cpupower_is_cpu_online(cpu) != 1.
In cpufreq-bench, which prints an error message for offline CPUs,
properly distinguish and report the zero and negative cases.
Reported-by: Jose <jjorge@free.fr>
Reported-by: Julien RIVAUD <frnchfrgg@free.fr>
Cc: stable <stable@vger.kernel.org> # 4.7+
Fixes: ac5a181d065d ("cpupower: Add cpuidle parts into library")
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
--- a/tools/power/cpupower/utils/cpufreq-set.c
+++ b/tools/power/cpupower/utils/cpufreq-set.c
@@ -296,7 +296,7 @@ int cmd_freq_set(int argc, char **argv)
struct cpufreq_affected_cpus *cpus;
if (!bitmask_isbitset(cpus_chosen, cpu) ||
- cpupower_is_cpu_online(cpu))
+ cpupower_is_cpu_online(cpu) != 1)
continue;
cpus = cpufreq_get_related_cpus(cpu);
@@ -316,10 +316,7 @@ int cmd_freq_set(int argc, char **argv)
cpu <= bitmask_last(cpus_chosen); cpu++) {
if (!bitmask_isbitset(cpus_chosen, cpu) ||
- cpupower_is_cpu_online(cpu))
- continue;
-
- if (cpupower_is_cpu_online(cpu) != 1)
+ cpupower_is_cpu_online(cpu) != 1)
continue;
printf(_("Setting cpu: %d\n"), cpu);
--- a/tools/power/cpupower/bench/system.c
+++ b/tools/power/cpupower/bench/system.c
@@ -58,12 +58,19 @@ long long int get_time()
int set_cpufreq_governor(char *governor, unsigned int cpu)
{
+ int rc;
dprintf("set %s as cpufreq governor\n", governor);
- if (cpupower_is_cpu_online(cpu) != 0) {
- perror("cpufreq_cpu_exists");
- fprintf(stderr, "error: cpu %u does not exist\n", cpu);
+ rc = cpupower_is_cpu_online(cpu);
+ if (rc != 1) {
+ if (rc < 0)
+ fprintf(stderr, "cpupower_is_cpu_online: %s\n",
+ strerror(-rc));
+ else
+ fprintf(stderr,
+ "error: cpu %u is offline or does not exist\n",
+ cpu);
return -1;
}

View File

@ -114,6 +114,7 @@ bugfix/alpha/alpha-uapi-add-support-for-__sane_userspace_types__.patch
bugfix/all/tools-build-remove-bpf-run-time-check-at-build-time.patch
bugfix/all/tools-lib-traceevent-fix-use-of-uninitialized-variables.patch
bugfix/all/cpupower-bump-soname-version.patch
bugfix/all/cpupower-fix-checks-for-cpu-existence.patch
bugfix/all/liblockdep-fix-undefined-symbol-prandom_u32.patch
bugfix/all/liblockdep-reduce-max_lock_depth-to-avoid-overflowin.patch
bugfix/all/liblockdep-define-the-array_size-macro.patch