Skip to content

Commit

Permalink
tools: cpupower: fix return checks for sysfs_get_idlestate_count()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Prarit Bhargava authored and Rafael J. Wysocki committed Dec 5, 2014
1 parent 009d043 commit 16b7c27
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tools/power/cpupower/utils/cpuidle-info.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@

static void cpuidle_cpu_output(unsigned int cpu, int verbose)
{
unsigned int idlestates, idlestate;
int idlestates, idlestate;
char *tmp;

printf(_ ("Analyzing CPU %d:\n"), cpu);

idlestates = sysfs_get_idlestate_count(cpu);
if (idlestates == 0) {
if (idlestates < 1) {
printf(_("CPU %u: No idle states\n"), cpu);
return;
}
Expand Down Expand Up @@ -100,10 +100,10 @@ static void cpuidle_general_output(void)
static void proc_cpuidle_cpu_output(unsigned int cpu)
{
long max_allowed_cstate = 2000000000;
unsigned int cstate, cstates;
int cstate, cstates;

cstates = sysfs_get_idlestate_count(cpu);
if (cstates == 0) {
if (cstates < 1) {
printf(_("CPU %u: No C-states info\n"), cpu);
return;
}
Expand Down

0 comments on commit 16b7c27

Please sign in to comment.