Cpu governor powersave - no effect

despite having this:
powerManagement.cpuFreqGovernor = lib.mkDefault "powersave";

in the hardware-configuration.nix, my cpu cores always run at the max frequency (performance governor).
Does this setting even work?

NixOS 20.03 with service ‘tlp’ enabled

thanks!

Edit: could it be related to:

Try

powerManagement.enable = true;
1 Like

If you want tlp, you should probably enable the service too. Here is a relevant part of my own configuration:

{ config, lib, pkgs, ... }: {
  # These optimations come from:
  # https://github.com/NixOS/nixpkgs/pull/22310#issuecomment-644863702

  environment.systemPackages = with pkgs;
    [ tlp powertop s-tui ] ++ [ config.boot.kernelPackages.cpupower ];

  system.activationScripts.cpu-frequency-set =
    let max-freq = 75; # 100 = the maximum capacity of my CPU
    in lib.mkIf (max-freq != null) {
      text = ''
        max_perf_pct=/sys/devices/system/cpu/intel_pstate/max_perf_pct
        value=${toString max-freq}
        if [[ -f $max_perf_pct ]]; then
          echo $value > $max_perf_pct
        fi
      '';
      deps = [ ];
    };

  powerManagement = {
    enable = true;
    powertop.enable = false;
  };

  services.tlp = {
    enable = true;
    # The following prevents the battery from charging fully to
    # preserve lifetime. Run `tlp fullcharge` to temporarily force
    # full charge.
    extraConfig = ''
      CPU_SCALING_GOVERNOR_ON_BAT=powersave
      ENERGY_PERF_POLICY_ON_BAT=powersave
      START_CHARGE_THRESH_BAT0=40
      STOP_CHARGE_THRESH_BAT0=50
    '';
  };
}

2 Likes

Thanks!

question remains, why does tlp reset the governor?

maybe @lovesegfault @abbradar knows

$ sudo nixos-option powerManagement.cpuFreqGovernor
warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels/nixos' does not exist, ignoring
Value:
null

Default:
null

Type:
"null or string"

Example:
"ondemand"

Description:
''
  Configure the governor used to regulate the frequence of the
  available CPUs. By default, the kernel configures the
  performance governor, although this may be overwritten in your
  hardware-configuration.nix file.

  Often used values: "ondemand", "powersave", "performance"
''

Declared by:
[ "/nix/var/nix/profiles/per-user/root/channels/nixpkgs/nixos/modules/tasks/cpu-freq.nix" ]

Defined by:
[ "/nix/var/nix/profiles/per-user/root/channels/nixpkgs/nixos/modules/services/hardware/tlp.nix" ]

I think because tlp has it own config to manage cpu governor. So if you use tlp, you can specify cpu governor in tlp config, example: Thinkpad T470s power management - #4 by thongpv87

2 Likes