[linux] 01/01: cpupower: Fix checks for CPU existence (Closes: #843071)

debian-kernel at lists.debian.org debian-kernel at lists.debian.org
Thu Nov 3 22:23:58 UTC 2016


This is an automated email from the git hooks/post-receive script.

benh pushed a commit to branch sid
in repository linux.

commit d88288583532be63ec75dff7dcb50ff03a0b7c85
Author: Ben Hutchings <ben at decadent.org.uk>
Date:   Thu Nov 3 16:11:35 2016 -0600

    cpupower: Fix checks for CPU existence (Closes: #843071)
---
 debian/changelog                                   |  1 +
 .../cpupower-fix-checks-for-cpu-existence.patch    | 72 ++++++++++++++++++++++
 debian/patches/series                              |  1 +
 3 files changed, 74 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index 417345c..99c9dc2 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 at 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 0000000..41dd357
--- /dev/null
+++ b/debian/patches/bugfix/all/cpupower-fix-checks-for-cpu-existence.patch
@@ -0,0 +1,72 @@
+From: Ben Hutchings <ben at 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 at free.fr>
+Reported-by: Julien RIVAUD <frnchfrgg at free.fr>
+Cc: stable <stable at vger.kernel.org> # 4.7+
+Fixes: ac5a181d065d ("cpupower: Add cpuidle parts into library")
+Signed-off-by: Ben Hutchings <ben at 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 968e787..f947dfd 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

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/kernel/linux.git



More information about the Kernel-svn-changes mailing list