diff options
author | Ben Hutchings <ben@decadent.org.uk> | 2016-11-03 16:11:35 -0600 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2016-11-03 16:11:35 -0600 |
commit | d88288583532be63ec75dff7dcb50ff03a0b7c85 (patch) | |
tree | 1a789c1fb36f5fde4eca1dba62b55a595c762b47 | |
parent | 18036575a78f52451930a2ea9ee9c9e0878bd6af (diff) |
cpupower: Fix checks for CPU existence (Closes: #843071)
-rw-r--r-- | debian/changelog | 1 | ||||
-rw-r--r-- | debian/patches/bugfix/all/cpupower-fix-checks-for-cpu-existence.patch | 72 | ||||
-rw-r--r-- | debian/patches/series | 1 |
3 files changed, 74 insertions, 0 deletions
diff --git a/debian/changelog b/debian/changelog index 417345c04..99c9dc2bc 100644 --- a/debian/changelog +++ b/debian/changelog @@ -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 diff --git a/debian/patches/bugfix/all/cpupower-fix-checks-for-cpu-existence.patch b/debian/patches/bugfix/all/cpupower-fix-checks-for-cpu-existence.patch new file mode 100644 index 000000000..41dd35745 --- /dev/null +++ b/debian/patches/bugfix/all/cpupower-fix-checks-for-cpu-existence.patch @@ -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; + } + diff --git a/debian/patches/series b/debian/patches/series index 968e787e3..f947dfdd9 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -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 |