Skip to contentSkip to conversation

tools, cpupower Fix error condition in cmd_freq_set()

PATCH In review Prarit Bhargava 1 participant 2 messages Feb 7, 2014 CPU power monitoring

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools, cpupower Fix error condition in cmd_freq_set()

On a system which has only 4.00GHz set as the only available frequency,

[root@amd-pike-05 ~]# cpupower frequency-info
<snip>
current policy: frequency should be within 4.00 GHz and 4.00 GHz.
The governor "userspace" may decide which speed to use within this range.
<snip>

setting the frequency to 2.8GHz does not return an error.

[root@amd-pike-05 ~]# cpupower frequency-set --freq 2800MHz Setting cpu: 0
Setting cpu: 1
Setting cpu: 2
Setting cpu: 3
Setting cpu: 4
Setting cpu: 5
Setting cpu: 6
Setting cpu: 7
[root@amd-pike-05 ~]#

The frequency set error should stop with an error message after the first failure. Fix the error return in cmd_freq_set() to read errors as less than zero.

Cc Dominik Brodowski <[email protected]>
Cc Thomas Renninger <[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>
Cc Alan Cox <[email protected]>
Cc One Thousand Gnomes <[email protected]>
---
 tools/power/cpupower/utils/cpufreq-set.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/power/cpupower/utils/cpufreq-set.c +1 -1
index a416de8..e5f78623 100644
@@ -320,7 +320,7 @@ int cmd_freq_set(int argc, char **argv)
 
 		printf(_("Setting cpu: %d\n"), cpu);
 		ret = do_one_cpu(cpu, &new_pol, freq, policychange);
-		if (ret)
+		if (ret < 0)
 			break;
 	}
 
Signature · 1 line
1.7.9.3
#1 lore raw
Quoted 41 lines · Prarit Bhargava

On a system which has only 4.00GHz set as the only available frequency,

[root@amd-pike-05 ~]# cpupower frequency-info
<snip>
current policy: frequency should be within 4.00 GHz and 4.00 GHz.
The governor "userspace" may decide which speed to use within this range.
<snip>

setting the frequency to 2.8GHz does not return an error.

[root@amd-pike-05 ~]# cpupower frequency-set --freq 2800MHz Setting cpu: 0
Setting cpu: 1
Setting cpu: 2
Setting cpu: 3
Setting cpu: 4
Setting cpu: 5
Setting cpu: 6
Setting cpu: 7
[root@amd-pike-05 ~]#

The frequency set error should stop with an error message after the first failure. Fix the error return in cmd_freq_set() to read errors as less than zero.

Cc Dominik Brodowski <[email protected]>
Cc Thomas Renninger <[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>
Cc Alan Cox <[email protected]>
Cc One Thousand Gnomes <[email protected]>
---
 tools/power/cpupower/utils/cpufreq-set.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/power/cpupower/utils/cpufreq-set.c +0 -0
index a416de8..e5f78623 100644

tools/power/cpupower/utils/cpufreq-set.c int cmd_freq_set(int argc, char **argv) · line 323

Quoted 5 lines
tools/power/cpupower/utils/cpufreq-set.c +1 -1
@@ -320,7 +320,7 @@ int cmd_freq_set(int argc, char **argv)
 
 		printf(_("Setting cpu: %d\n"), cpu);
 		ret = do_one_cpu(cpu, &new_pol, freq, policychange);
-		if (ret)
+		if (ret < 0)

Self-nack ... this won't work.

P.

Quoted 3 lines
tools/power/cpupower/utils/cpufreq-set.c +0 -0
 			break;
 	}