From cf36b3db809da129e2046d4948082d1ed0ac09ec Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 20 Dec 2011 22:44:58 +0000 Subject: [PATCH] =?UTF-8?q?*=20If=20power=20management=20is=20enabled,=20s?= =?UTF-8?q?et=20the=20governor=20to=20=E2=80=98ondemand=E2=80=99=20by=20?= =?UTF-8?q?=20=20default.=20=20See?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit http://www.codon.org.uk/~mjg59/power/good_practices.html for the reasoning. (Basically, the ‘performance’ and ‘powersave’ governors don't actually provide extra performance or power savings in most cases.) It used to be that desktop environments like KDE were able to set the governor through HAL (e.g. KDE could be configured to switch to the powersave governor when the user unplugs his laptop). However, this is no longer the case with upower — it is now expected that everybody uses the ondemand governor. See http://old.nabble.com/-PATCH--powerdevil-remove-cpufreq.patch-td27815354.html * Rename ‘cpuFreqGovernor’ to ‘powerManagement.cpuFreqGovernor’. * Include cpufreq-utils in the system path if a governor is set, since we depend on it anyway. svn path=/nixos/trunk/; revision=30991 --- modules/config/power-management.nix | 2 ++ modules/tasks/cpu-freq.nix | 16 +++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/modules/config/power-management.nix b/modules/config/power-management.nix index cb7047a2ba80..10aa821964a8 100644 --- a/modules/config/power-management.nix +++ b/modules/config/power-management.nix @@ -91,6 +91,8 @@ in "p4_clockmod" ]; + powerManagement.cpuFreqGovernor = "ondemand"; + }; } diff --git a/modules/tasks/cpu-freq.nix b/modules/tasks/cpu-freq.nix index 6498b45a6352..b7d9756db1b5 100644 --- a/modules/tasks/cpu-freq.nix +++ b/modules/tasks/cpu-freq.nix @@ -6,7 +6,8 @@ with pkgs.lib; ###### interface options = { - cpuFreqGovernor = mkOption { + + powerManagement.cpuFreqGovernor = mkOption { default = ""; example = "ondemand"; description = '' @@ -15,13 +16,17 @@ with pkgs.lib; "userspace". ''; }; + }; ###### implementation - config = mkIf (config.cpuFreqGovernor != "") ({ - jobs.cpuFreq = + config = mkIf (config.powerManagement.cpuFreqGovernor != "") { + + environment.systemPackages = [ pkgs.cpufrequtils ]; + + jobs.cpufreq = { description = "Initialize CPU frequency governor"; startOn = "started udev"; @@ -30,10 +35,11 @@ with pkgs.lib; script = '' for i in $(seq 0 $(($(nproc) - 1))); do - ${pkgs.cpufrequtils}/bin/cpufreq-set -g ${config.cpuFreqGovernor} -c $i + ${pkgs.cpufrequtils}/bin/cpufreq-set -g ${config.powerManagement.cpuFreqGovernor} -c $i done ''; }; - }); + + }; }