I have the following in my configuration.nix:
powerManagement = {
enable = true;
cpuFreqGovernor = "powersave";
};
But when I boot, the governor is set to performance
"x86_64-linux"Linux 4.19.57, NixOS, 19.03.173052.aef662d2eb5 (Koi)yesyesnix-env (Nix) 2.2.2"nixpkgs-19.09pre184359.73392e79aa6""nixos-19.03.173052.aef662d2eb5, nixos-hardware, nixpkgs-unstable-19.09pre182717.b58ada326aa"/home/felix/.nix-defexpr/channels/nixpkgsIs there anything in the journal / kernel logs related to this?
What does systemctl status cpufreq.service say?
cat /sys/bus/cpu/devices/cpu*/cpufreq/scaling_available_governors might be useful as well, to see what governors are supported on your system.
$ cat /sys/bus/cpu/devices/cpu*/cpufreq/scaling_available_governors
performance powersave
performance powersave
performance powersave
performance powersave
performance powersave
performance powersave
performance powersave
performance powersave
Ah! This might be the issue:
$ systemctl status cpufreq.service
Unit cpufreq.service could not be found.
Ok, that service should be enabled according to your config.
Stupid question: you did rebuild your system configuration, right?
Also there usually is an entry powerManagement.cpuFreqGovernor = lib.mkDefault [..] in hardware-configuration.nix, does that exist?
I have the same issue.
In my hardware configuration that entry exists and the governor is set to "powersave" as well (same as in my configuration.nix.
But it is not applied.
Unit does not exist:
$ systemctl status cpufreq.service
Unit cpufreq.service could not be found.
$ systemctl --user status cpufreq.service
Unit cpufreq.service could not be found.
cpupower confirms that my cpu supports "powersave" governor:
$ 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: 400 MHz - 4.00 GHz
available cpufreq governors: performance powersave
current policy: frequency should be within 400 MHz and 4.00 GHz.
The governor "performance" may decide which speed to use
within this range.
current CPU frequency: Unable to call hardware
current CPU frequency: 3.72 GHz (asserted by call to kernel)
boost state support:
Supported: yes
Active: yes
Setting in manually with cpupower does work.
Therefore I guess it is the cpufreq service and not a configurational thing.
Ah yes, happens to me as well now. ~One~ ~of~ ~my~ ~boxes~ ~hasn't~ ~upgraded~ ~yet~ ~and~ ~is~ ~fine~ ~on~ ~nixos-19.09pre184759.88c2586958,~ ~the~ ~other~ ~has~ ~(to~ ~nixos-19.09pre184855.beff2f8d75e)~ ~and~ ~exhibits~ ~this~ ~bug.~ ~So~ ~it~ ~was~ ~likely~ ~introduced~ ~between~ ~those.~
Hmm it appears that the machine in question did not have a default for the governor set in hardware-configuration.nix.
After setting it explicitly, it does work.
Stupid question: you did rebuild your system configuration, right?
Yes, I did. :wink:
Also there usually is an entry
powerManagement.cpuFreqGovernor = lib.mkDefault [..]in
hardware-configuration.nix, does that exist?
I removed it. It was set to performance. Should it make a difference? Should I add it again?
No, explicitly setting powerManagement.cpuFreqGovernor should be sufficient.
What does nixos-option powerManagement.cpuFreqGovernor say?
โฏ nixos-option powerManagement.cpuFreqGovernor
Value:
null
Default:
null
Example:
"ondemand"
Description:
"Configure the governor used to regulate the frequence of the\navailable CPUs. By default, the kernel configures the\nperformance governor, although this may be overwritten in your\nhardware-configuration.nix file.\n\nOften used values: \"ondemand\", \"powersave\", \"performance\"\n"
Declared by:
"/home/felix/.nix-defexpr/channels/nixpkgs/nixos/modules/tasks/cpu-freq.nix"
Defined by:
"/nix/var/nix/profiles/per-user/root/channels/nixos-hardware/common/pc/laptop"
Aah, so it turns out that nixos-hardware disables the setting if tlp is enabled:
So either disabling tlp or configuring tlp itself to set the governor you want should fix the problem.
Does powerManagement.enable = true enable tlp somehow? I didn't enable it explicitly in my config.
No, but nixos-hardware's laptop profile does.
Aah, so it turns out that nixos-hardware disables the setting if tlp is enabled:
So either disabling tlp or configuring tlp itself to set the governor you want should fix the problem.
Hey,
thanks - enabling tlp in the nixos configuration.nix and providing some extraConfigs like setting the governor seems to work as expected.
It may be worth to add a hint in to the powerManagement and / or powerManagement.cpuFreqGovernor settings ;-)
extraConfig = ''
tlp_DEFAULT_MODE=BAT
CPU_SCALING_GOVERNOR_ON_BAT=powersave
'';
Thank you for your contributions.
This has been automatically marked as stale because it has had no activity for 180 days.
If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.
Here are suggestions that might help resolve this more quickly:
Most helpful comment