Bug 135391 - cpupower does not change the governor anymore
Summary: cpupower does not change the governor anymore
Status: RESOLVED CODE_FIX
Alias: None
Product: Tools
Classification: Unclassified
Component: Other (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: Tools.Other
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-07-16 14:16 UTC by Jose
Modified: 2016-12-04 09:26 UTC (History)
10 users (show)

See Also:
Kernel Version: 4.7-rc7
Subsystem:
Regression: No
Bisected commit-id:


Attachments
this is what I ended up using as a fix(for me) (998 bytes, patch)
2016-08-11 00:02 UTC, elvis has left the building
Details | Diff

Description Jose 2016-07-16 14:16:54 UTC
This seems a trivial bug : it looks like cpupower can't set the governor anymore :

== cpupower frequency-set -g powersave

does nothing (ie the governor is still performance) while

== echo powersave > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

does the job.

It is very easy to reproduce.
Comment 1 Ben Kohler 2016-08-08 14:24:52 UTC
I see the same behavior here.  I did a bisect and this commit appears to be the culprit:
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/tools/power/cpupower?id=ac5a181d065d74fb6b213d538f743392f27bcdbd
Comment 2 elvis has left the building 2016-08-10 23:49:56 UTC
So here's the thing: invocations of cpufreq_cpu_exists got replaced by cpupower_is_cpu_online
but the logic is different!


----old version:
 returns 0 if the specified CPU is present (it doesn't say
 - * whether it is online!), and an error value if not.
 - */
 -
 -extern int cpufreq_cpu_exists(unsigned int cpu);

----new version:

* Detect whether a CPU is online
 + *
 + * Returns:
 + *     1 -> if CPU is online
 + *     0 -> if CPU is offline
 + *     negative errno values in error case
 + */
 +int cpupower_is_cpu_online(unsigned int cpu)
 +{

source: https://github.com/torvalds/linux/commit/ac5a181d065d74fb6b213d538f743392f27bcdbd

Now, I can confirm this works for me:
two cases needed a not (aka "!"):
this
https://github.com/torvalds/linux/commit/ac5a181d065d74fb6b213d538f743392f27bcdbd#diff-0d2591a0e5c1bea4b5b35758e0726657R299
and
https://github.com/torvalds/linux/commit/ac5a181d065d74fb6b213d538f743392f27bcdbd#diff-0d2591a0e5c1bea4b5b35758e0726657R319

There's probably more cases, but I only needed the gov and freq set. And I haven't tested anything else for now.

tested kernel: 4.8.0-rc1-g9512c47

Cheers my friends!
Comment 3 elvis has left the building 2016-08-11 00:02:48 UTC
Created attachment 228271 [details]
this is what I ended up using as a fix(for me)




works for me.

-------before:
$ cpunorm
modprobe: FATAL: Module msr not found in directory /lib/modules/4.8.0-rc1-g9512c47
  current policy: frequency should be within 1.40 GHz and 1.40 GHz.
                  The governor "performance" may decide which speed to use
  current CPU frequency: Unable to call hardware
  current CPU frequency: 1.40 GHz (asserted by call to kernel)


-------after:
//[2016-08-11 03:00] [ALPM] upgraded cpupower (4.7-1 -> 4.8.rc1.r70.g9512c47-1)

$ cpunorm
modprobe: FATAL: Module msr not found in directory /lib/modules/4.8.0-rc1-g9512c47
Setting cpu: 0
Setting cpu: 1
Setting cpu: 2
Setting cpu: 3
  current policy: frequency should be within 800 MHz and 1.40 GHz.
                  The governor "ondemand" may decide which speed to use
  current CPU frequency: Unable to call hardware
  current CPU frequency: 1.40 GHz (asserted by call to kernel)
Comment 4 Jose 2016-10-11 14:40:08 UTC
Well, can someone apply this patch upstream if it fixes the bug?

Thanks.
Comment 5 Chris Denice 2016-10-12 12:25:24 UTC
Yes, that would be nice guys, still not fixed on 4.8.1, which is annoying for computing servers based on intel_pstates which default on powersave.
Comment 6 Chris Denice 2016-10-25 13:38:11 UTC
Ping?
still not fixed on 4.8.3...
Comment 7 Mattia Dongili 2016-11-04 13:34:59 UTC
Added Thomas to the CC list.

I don't know how to edit the fields at the top, but this bug needs the attention of the right developers.
Comment 8 foudil.newbie+linux 2016-11-21 20:30:05 UTC
This has been fixed recently in commit c25badc, which will pop up in v4.9 I think.
See also: https://bugzilla.kernel.org/show_bug.cgi?id=153221

So I guess this bug can be closed.
Comment 9 Jose 2016-12-04 09:26:04 UTC
Yes, confirmed

Note You need to log in before you can comment on or make changes to this bug.