3
0
Fork 0
forked from mirrors/nixpkgs

cpu-freq: Try powersave if ondemand is not available

This commit is contained in:
Alex Ivanov 2016-12-26 12:41:59 +03:00
parent b20fdff521
commit 4dc56db37e
2 changed files with 13 additions and 8 deletions

View file

@ -69,8 +69,8 @@ in
config = mkIf cfg.enable {
# FIXME: Implement powersave governor for sandy bridge or later Intel CPUs
powerManagement.cpuFreqGovernor = mkDefault "ondemand";
# ondemand governor is not available on sandy bridge or later Intel CPUs
powerManagement.cpuFreqGovernor = mkDefault [ "ondemand" "powersave" ];
systemd.targets.post-resume = {
description = "Post-Resume Actions";

View file

@ -13,9 +13,9 @@ in
options = {
powerManagement.cpuFreqGovernor = mkOption {
type = types.nullOr types.str;
default = null;
example = "ondemand";
type = types.listOf types.str;
default = [];
example = [ "ondemand" ];
description = ''
Configure the governor used to regulate the frequence of the
available CPUs. By default, the kernel configures the
@ -28,9 +28,9 @@ in
###### implementation
config = mkIf (!config.boot.isContainer && config.powerManagement.cpuFreqGovernor != null) {
config = mkIf (!config.boot.isContainer && config.powerManagement.cpuFreqGovernor != []) {
boot.kernelModules = [ "cpufreq_${cfg.cpuFreqGovernor}" ];
boot.kernelModules = map (x: "cpufreq_" + x) cfg.cpuFreqGovernor;
environment.systemPackages = [ cpupower ];
@ -43,7 +43,12 @@ in
serviceConfig = {
Type = "oneshot";
RemainAfterExit = "yes";
ExecStart = "${cpupower}/bin/cpupower frequency-set -g ${cfg.cpuFreqGovernor}";
ExecStart = ''
${pkgs.bash}/bin/sh -c \
"for i in ${toString cfg.cpuFreqGovernor}; do \
${cpupower}/bin/cpupower frequency-set -g $i && break; \
done"
'';
SuccessExitStatus = "0 237";
};
};