1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-20 04:31:52 +00:00

cpu-freq: Use cpupower instead of cpufrequtils

Additionally, put the powersave utility in charge of loading the
cpufrequency modules based on the governor specified in the
configuration.
This commit is contained in:
William A. Kennington III 2014-03-17 18:07:46 -05:00 committed by Eelco Dolstra
parent 171a58bcd6
commit dd209e901c
2 changed files with 23 additions and 26 deletions

View file

@ -65,11 +65,7 @@ in
config = mkIf cfg.enable { config = mkIf cfg.enable {
boot.kernelModules = # FIXME: Implement powersave governor for sandy bridge or later Intel CPUs
[ "acpi_cpufreq" "powernow-k8" "cpufreq_performance" "cpufreq_powersave" "cpufreq_ondemand"
"cpufreq_conservative"
];
powerManagement.cpuFreqGovernor = mkDefault "ondemand"; powerManagement.cpuFreqGovernor = mkDefault "ondemand";
powerManagement.scsiLinkPolicy = mkDefault "min_power"; powerManagement.scsiLinkPolicy = mkDefault "min_power";

View file

@ -2,6 +2,11 @@
with lib; with lib;
let
cpupower = config.boot.kernelPackages.cpupower;
cfg = config.powerManagement;
in
{ {
###### interface ###### interface
@ -25,29 +30,25 @@ with lib;
config = mkIf (config.powerManagement.cpuFreqGovernor != null) { config = mkIf (config.powerManagement.cpuFreqGovernor != null) {
environment.systemPackages = [ pkgs.cpufrequtils ]; boot.kernelModules = [ "acpi-cpufreq" "speedstep-lib" "pcc-cpufreq"
"cpufreq_${cfg.cpuFreqGovernor}"
];
jobs.cpufreq = environment.systemPackages = [ cpupower ];
{ description = "CPU Frequency Governor Setup";
after = [ "systemd-modules-load.service" ]; systemd.services.cpufreq = {
wantedBy = [ "multi-user.target" ]; description = "CPU Frequency Governor Setup";
after = [ "systemd-modules-load.service" ];
unitConfig.ConditionPathIsReadWrite = "/sys/devices/"; wantedBy = [ "multi-user.target" ];
path = [ cpupower ];
path = [ pkgs.cpufrequtils ]; script = ''
cpupower frequency-set -g ${cfg.cpuFreqGovernor}
preStart = '' '';
for i in $(seq 0 $(($(nproc) - 1))); do serviceConfig = {
for gov in $(cpufreq-info -c $i -g); do Type = "oneshot";
if [ "$gov" = ${config.powerManagement.cpuFreqGovernor} ]; then RemainAfterExit = "yes";
echo "<6>setting governor on CPU $i to $gov"
cpufreq-set -c $i -g $gov
fi
done
done
'';
}; };
}; };
};
} }