diff options
author | Prarit Bhargava <prarit@redhat.com> | 2014-12-01 09:39:22 -0500 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2014-12-04 21:12:34 -0500 |
commit | 16b7c275c055cc36218404b5d147be7f76575087 (patch) | |
tree | c7b170c8eab5c804e5fd74958e22b76c4cb0b880 /tools/power | |
parent | 009d0431c3914de64666bec0d350e54fdd59df6a (diff) |
tools: cpupower: fix return checks for sysfs_get_idlestate_count()
Red Hat and Fedora use a bug reporting tool that gathers data about
"broken" systems called sosreport. Among other things, it includes the
output of 'cpupower idle-info'. Executing 'cpupower idle-info' on a
system that has cpuidle disabled via 'cpuidle.off=1' results in a 300
second hang in the cpupower application.
ie)
[root@intel-brickland-05]# cpupower idle-info
Could not determine cpuidle driver
Analyzing CPU 0:
Number of idle states: -19
[hang]
The problem is that the cpupower code only checks for a zero return from
sysfs_get_idlestate_count(). The function can return -ENODEV (-19) as
above. This patch fixes callers to sysfs_get_idlestate_count() to check
the right return values.
Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Signed-off-by: Thomas Renninger <trenn@suse.de>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'tools/power')
-rw-r--r-- | tools/power/cpupower/utils/cpuidle-info.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/tools/power/cpupower/utils/cpuidle-info.c b/tools/power/cpupower/utils/cpuidle-info.c index 75e66de7e7a7..458d69b444ad 100644 --- a/tools/power/cpupower/utils/cpuidle-info.c +++ b/tools/power/cpupower/utils/cpuidle-info.c | |||
@@ -22,13 +22,13 @@ | |||
22 | 22 | ||
23 | static void cpuidle_cpu_output(unsigned int cpu, int verbose) | 23 | static void cpuidle_cpu_output(unsigned int cpu, int verbose) |
24 | { | 24 | { |
25 | unsigned int idlestates, idlestate; | 25 | int idlestates, idlestate; |
26 | char *tmp; | 26 | char *tmp; |
27 | 27 | ||
28 | printf(_ ("Analyzing CPU %d:\n"), cpu); | 28 | printf(_ ("Analyzing CPU %d:\n"), cpu); |
29 | 29 | ||
30 | idlestates = sysfs_get_idlestate_count(cpu); | 30 | idlestates = sysfs_get_idlestate_count(cpu); |
31 | if (idlestates == 0) { | 31 | if (idlestates < 1) { |
32 | printf(_("CPU %u: No idle states\n"), cpu); | 32 | printf(_("CPU %u: No idle states\n"), cpu); |
33 | return; | 33 | return; |
34 | } | 34 | } |
@@ -100,10 +100,10 @@ static void cpuidle_general_output(void) | |||
100 | static void proc_cpuidle_cpu_output(unsigned int cpu) | 100 | static void proc_cpuidle_cpu_output(unsigned int cpu) |
101 | { | 101 | { |
102 | long max_allowed_cstate = 2000000000; | 102 | long max_allowed_cstate = 2000000000; |
103 | unsigned int cstate, cstates; | 103 | int cstate, cstates; |
104 | 104 | ||
105 | cstates = sysfs_get_idlestate_count(cpu); | 105 | cstates = sysfs_get_idlestate_count(cpu); |
106 | if (cstates == 0) { | 106 | if (cstates < 1) { |
107 | printf(_("CPU %u: No C-states info\n"), cpu); | 107 | printf(_("CPU %u: No C-states info\n"), cpu); |
108 | return; | 108 | return; |
109 | } | 109 | } |