From ae82e7b048e8ef1f402e0e9cfbaf3b1d04bf8052 Mon Sep 17 00:00:00 2001 From: Peter Simons Date: Fri, 16 Dec 2011 23:44:37 +0000 Subject: [PATCH] Added cpuFreqGovernor option to configure a CPU frequency governor. svn path=/nixos/trunk/; revision=30949 --- modules/module-list.nix | 1 + modules/tasks/cpu-freq.nix | 39 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 modules/tasks/cpu-freq.nix diff --git a/modules/module-list.nix b/modules/module-list.nix index a44e1c6e422..80f52be37f3 100644 --- a/modules/module-list.nix +++ b/modules/module-list.nix @@ -190,6 +190,7 @@ ./system/upstart-events/runlevel.nix ./system/upstart-events/shutdown.nix ./system/upstart/upstart.nix + ./tasks/cpu-freq.nix ./tasks/filesystems.nix ./tasks/kbd.nix ./tasks/lvm.nix diff --git a/modules/tasks/cpu-freq.nix b/modules/tasks/cpu-freq.nix new file mode 100644 index 00000000000..6498b45a635 --- /dev/null +++ b/modules/tasks/cpu-freq.nix @@ -0,0 +1,39 @@ +{ config, pkgs, ... }: + +with pkgs.lib; + +{ + ###### interface + + options = { + cpuFreqGovernor = mkOption { + default = ""; + example = "ondemand"; + description = '' + Configure the governor used to regulate the frequence of the + available CPUs. By default, the kernel configures the governor + "userspace". + ''; + }; + }; + + + ###### implementation + + config = mkIf (config.cpuFreqGovernor != "") ({ + jobs.cpuFreq = + { description = "Initialize CPU frequency governor"; + + startOn = "started udev"; + + task = true; + + script = '' + for i in $(seq 0 $(($(nproc) - 1))); do + ${pkgs.cpufrequtils}/bin/cpufreq-set -g ${config.cpuFreqGovernor} -c $i + done + ''; + }; + }); + +}