Arch Linux

Please read this before reporting a bug:

Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.

REPEAT: Do NOT report bugs for outdated packages!

FS#65543 - [linux] cpupower unable to change frequency and governor for kernel >= 5.5.3

Attached to Project: Arch Linux
Opened by Marcin Rzeźnicki (mrzeznicki) - Tuesday, 18 February 2020, 14:02 GMT
Last edited by Jan Alexander Steffens (heftig) - Friday, 06 March 2020, 15:41 GMT
Task Type Bug Report
Category Packages: Core
Status Closed
Assigned To Tobias Powalowski (tpowa)
Jan Alexander Steffens (heftig)
Architecture x86_64
Severity High
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No


I am not sure if this belongs to upstream or not. I've been checking new kernel bug reports but nothing is coming up - also, people on non-Intel CPUs (not using intel-pstate) seem to be unaffected.

Upgrading kernel to >= 5.5.4 seems to be breaking cpupower. Downgrading cpupower to 5.5.4-3 does not help, so this is on kernel. The last working version is 5.5.2-2.

cpupower.service fails to start resulting in frequency policy not applied:

● cpupower.service - Apply cpupower configuration
Loaded: loaded (/usr/lib/systemd/system/cpupower.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Mon 2020-02-17 17:24:56 CET; 25min ago
Process: 573 ExecStart=/usr/lib/systemd/scripts/cpupower (code=exited, status=1/FAILURE)
Main PID: 573 (code=exited, status=1/FAILURE)
CPU: 9ms

Trying to invoke the script by hand ends with:

> cpupower frequency-set -g powersave -d 800MHz -u 4500MHz
> Setting cpu: 0
> wrong, unknown or unhandled CPU?
> Error setting new values. Common errors:

Similarily cpupower-gui throws:

File "/usr/lib/cpupower-gui/cpupower-gui-helper", line 144, in read_governor
governor = sys_file.readline().strip()
OSError: [Errno 22] Invalid argument

I did a little debugging session using strace. The problem seems to result from failure to read /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor - the file is mysteriously empty on my machine after the upgrade

openat(AT_FDCWD, "/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor", O_RDONLY) = 3
read(3, 0x7ffce74e49e0, 4095) = -1 EINVAL (Invalid argument)

Trying to read the current cpupower settings is broken as well

> cpupower frequency-info
> analyzing CPU 0:
> driver: intel_pstate
> CPUs which run at the same hardware frequency: 0
> CPUs which need to have their frequency coordinated by software: 0
> maximum transition latency: Cannot determine or is not supported.
> hardware limits: 800 MHz - 4.50 GHz
> available cpufreq governors: performance powersave
> Unable to determine current policy
> current CPU frequency: Unable to call hardware
> current CPU frequency: 4.12 GHz (asserted by call to kernel)
> boost state support:
> Supported: yes
> Active: yes
This task depends upon

Closed by  Jan Alexander Steffens (heftig)
Friday, 06 March 2020, 15:41 GMT
Reason for closing:  Fixed
Additional comments about closing:  5.5.8
Comment by loqs (loqs) - Tuesday, 18 February 2020, 14:49 GMT Comment by Marcin Rzeźnicki (mrzeznicki) - Tuesday, 18 February 2020, 15:43 GMT Comment by loqs (loqs) - Tuesday, 18 February 2020, 18:52 GMT
If you revert all three commits and check if the issue is still present. Then re apply the commits one at a time checking the state of the issue you would only need to do one full kernel rebuild.
Comment by Marcin Rzeźnicki (mrzeznicki) - Wednesday, 19 February 2020, 15:07 GMT
Thanks for the tip! I must admit I've never done it but I think I can manage. I'll try to pull it off tomorrow
Comment by loqs (loqs) - Wednesday, 19 February 2020, 20:34 GMT
Obtain the PKGBUILD [1] then

makepkg -ors #download the source and run prepare
cd src/archlinux-linux
git revert -n 41ddb7e1f79693d904502ae9bea609837973eff8
git revert -n ae2917093fb60bdc1ed3e5757b74801420569a9
git revert -n 16d51c1c10ed9993c5d97c3126ceac5b579c60b7
cd ../..
makepkg -ersi # build the modified source and install it and test if the issue is fixed.

If the issue was fixed by that to re apply the last reverted commit
cd src/archlinux-linux
git cherry-pick -n 16d51c1c10ed9993c5d97c3126ceac5b579c60b7
cd ../..
makepkg -ersi # build the modified source and install it check if that reintroduced the issue.

Then repeat for the other two commits if needed.

Comment by Marcin Rzeźnicki (mrzeznicki) - Wednesday, 19 February 2020, 21:39 GMT
The link is much helpful - never used ABS and didn't think I can just `-ors` in mapkepkg. Wonderful, easier than I thought. I thought I'd have to build it from scratch :embarassed: Thanks!
Comment by Carlos (cyberconan) - Monday, 02 March 2020, 00:52 GMT
Hi! It's a strange issue. If I do:
sudo systemctl restart cpupower.service
Job for cpupower.service failed because the control process exited with error code.
See "systemctl status cpupower.service" and "journalctl -xe" for details.

Then I edit /etc/default/cpupower and comment this lines:

I restart service and now all works but... if I uncomment freq lines and restart, every setting than I have in cpupower works with no errors.

Comment by Marcin Rzeźnicki (mrzeznicki) - Monday, 02 March 2020, 16:24 GMT
Hello carlos. You're right, it's been reported by various users on the archlinux's reddit thread . So setting governor should work, but setting frequencies on Intel will not. I didn't check other settings, but if you see that "every [other] setting" works, then I guess it confirms these observations. Unfortunately, I didn't have time to reproduce it yet :-/
Comment by Carlos (cyberconan) - Monday, 02 March 2020, 19:25 GMT
Ok, then we can only wait a fix. Thanks!
Comment by Marcin Rzeźnicki (mrzeznicki) - Friday, 06 March 2020, 15:37 GMT
This bug seems to have been fixed in 5.5.8 - which strongly suggests that the commit that fixed this was, which means that commit that broke it was at the end of January by the same author. Judging by his e-mail he is working for Intel, so he managed to break cpupower for CPUs he is using :clap clap:. Anyways, thanks everyone for your help - I think this bug may be closed as fixed in 5.5.8.