r/NixOS•
wfdctrl

CPU frequency 2x after waking from suspend

When I reboot the frequency of the CPU is around 1.2GHz (according to cpupower frequency-info). However when I wake it up from suspend the frequency is around 2.0GHz and I stays like that indefinitely. The CPU is in "powersave" mode in both cases.

NixOS version 21.05

analyzing CPU 0:
  driver: intel_cpufreq
  CPUs which run at the same hardware frequency: 0
  CPUs which need to have their frequency coordinated by software: 0
  maximum transition latency: 20.0 us
  hardware limits: 1.20 GHz - 3.30 GHz
  available cpufreq governors: powersave performance schedutil
  current policy: frequency should be within 1.20 GHz and 3.30 GHz.
                  The governor "powersave" may decide which speed to use
                  within this range.
  current CPU frequency: Unable to call hardware
  current CPU frequency: 1.24 GHz (asserted by call to kernel)
  boost state support:
    Supported: yes
    Active: yes
    25500 MHz max turbo 4 active cores
    25500 MHz max turbo 3 active cores
    25500 MHz max turbo 2 active cores
    25500 MHz max turbo 1 active cores

analyzing CPU 0:
  driver: intel_cpufreq
  CPUs which run at the same hardware frequency: 0
  CPUs which need to have their frequency coordinated by software: 0
  maximum transition latency: 20.0 us
  hardware limits: 1.20 GHz - 3.30 GHz
  available cpufreq governors: powersave performance schedutil
  current policy: frequency should be within 1.20 GHz and 3.30 GHz.
                  The governor "powersave" may decide which speed to use
                  within this range.
  current CPU frequency: Unable to call hardware
  current CPU frequency: 2.24 GHz (asserted by call to kernel)
  boost state support:
    Supported: yes
    Active: yes
    25500 MHz max turbo 4 active cores
    25500 MHz max turbo 3 active cores
    25500 MHz max turbo 2 active cores
    25500 MHz max turbo 1 active cores

Any idea what is causing this? Does anyone else experience the same thing?

Steps to reproduce:

  1. systemctl reboot
  2. cpupower frequency-info
  3. systemctl suspend
  4. cpupower frequency-info

Posted Sep 5, 2021, 10:38 AM UTC · edited

104
futureZenik•
  • I occasionally experience a similar thing you describe, where after wake from suspend the CPU's max frequency is the base frequency, and it doesn't turbo boost. I just toggle the CPU governor using the below shell script, and it "unsticks" it. Also you can use s-tui to stress CPU and view frequencies and make sure it boosts correctly.

# fixes cpu getting stuck at 2.195 Ghz, and return to 3.295 Ghz turbo.

cpupower frequency-set -g schedutil

cpupower frequency-set -g performance

2
wfdctrlOP•

Yep, that fixes it. I originally thought that NixOS does something clever when waking up, but it seems like it might just be a kernel issue or something. Thanks :)

1

oh man, it's so nice when someone else has the similar problem lol. I've been trying to fix exact problem. Turbo boost doesn't work from suspend, but works from reboot or hibernation. I've tried numerous things: changing intel_pstate to acpi_cpufreq driver, changing governors, disabling TLP , changing kernels and etc. Althought all CPU info programs show that turbo boost is available and enabled when waking up from suspend. Maybe it's a hardware thing? Mine is i5-2520M processor (Thinkpad T420)? Thanks, will use the script!

1

for future reference for anyone (put this in configuration.nix):

powerManagement.resumeCommands = ''
${pkgs.linuxPackages.cpupower}/bin/cpupower frequency-set -g schedutil

${pkgs.linuxPackages.cpupower}/bin/cpupower frequency-set -g performance
'';
1