Fixed broken link
update needed for when we want to use cpupower
|Deletions are marked like this.||Additions are marked like this.|
|Line 9:||Line 9:|
|The [[https://www.kernel.org/pub/linux/utils/kernel/cpufreq/cpufreq-set.html|Linux kernel CPUfreq subsystem]] provides this ability on Debian Linux systems.||The [[https://www.kernel.org/pub/linux/utils/kernel/cpufreq/cpufreq-set.html|Linux kernel CPUfreq subsystem]] provides this ability on Debian Linux systems. ''Update would be welcome, cpufreq is being replaced by [[DebianPkg:linux-cpupower|cpupower]].''|
CPU frequency scaling
Dynamic CPU frequency scaling (also known as CPU throttling) is a technique in computer architecture where a processor is run at a less-than-maximum frequency in order to conserve power (src: Wikipedia).
The Linux kernel CPUfreq subsystem provides this ability on Debian Linux systems.
Update would be welcome, cpufreq is being replaced by cpupower.
Note: In most cases, this should be enabled automatically during Debian installation.
Install the cpufrequtils package:
aptitude install cpufrequtils
Specify the governor to use at boot
Edit /etc/default/cpufrequtils (you might need to create it if it doesn't exist). Specify the governor with the GOVERNOR variable:
# valid values: userspace conservative powersave ondemand performance # get them from cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors GOVERNOR="conservative"
Keeping the governor settings between boots
aptitude install sysfsutils
The sysfs values will be configured in /etc/sysfs.conf.
Here are some examples for the conservative governor:
# by default it's 444, so we have to change permissions to be able to change values mode devices/system/cpu/cpufreq/conservative = 644 devices/system/cpu/cpufreq/conservative/freq_step = 10 devices/system/cpu/cpufreq/conservative/up_threshold = 45 devices/system/cpu/cpufreq/conservative/ignore_nice_load = 1 devices/system/cpu/cpufreq/conservative/sampling_down_factor = 10
After you made the changes in /etc/sysfs.conf, apply them with /etc/init.d/sysfsutils start or with service sysfsutils start.
Check how CPU is configured
Either add "CPU Frequency Scaling Monitor" to your GNOME panel, or install the package cpufrequtils and run the command cpufreq-info, which prints one block like this per core:
analyzing CPU 0: driver: acpi-cpufreq CPUs which need to switch frequency at the same time: 0 hardware limits: 1000 MHz - 1.83 GHz available frequency steps: 1.83 GHz, 1.33 GHz, 1000 MHz available cpufreq governors: userspace, powersave, conservative, ondemand, performance current policy: frequency should be within 1000 MHz and 1.83 GHz. The governor "ondemand" may decide which speed to use within this range. current CPU frequency is 1000 MHz (asserted by call to hardware). cpufreq stats: 1.83 GHz:10.34%, 1.33 GHz:0.62%, 1000 MHz:89.04% (1068280)
There are two important pieces of information:
The statement The governor "ondemand", which means that this governor is loaded and enabled.
The statement current CPU frequency is XXXX MHz; if XXXX is lower than maximum speed, it probably means that it's working.
The governor decides what frequency should be used (it uses the CPUFreq driver to actually switch the CPU's policy). As explained above, since Lenny, the CPUFreq modules should be loaded using cpufrequtils.
In most cases, ondemand is the recommended governor. CPUFreq governors are actually modules (even though governors are modules, you should use cpufreq-info to know if the governors are loaded, and which one is active).
For more information about governors, read governors.txt (available in /usr/share/doc/linux-doc-2.6.32/Documentation/cpu-freq/ from the package linux-doc-2.6, you can read the latest version from kernel.org).
The userland-based governors (e.g. cpufreqd) are usually not needed any more.
As explained above, the governor defines the frequency scaling policy, but it doesn't instruct the CPU to change the speed directly... it needs a driver for that. cpufrequtils has an init script that should load the appropriate driver at boot time.
The list of CPUFreq drivers available on your system can be obtained by running:
/sbin/modinfo /lib/modules/$(uname -r)/kernel/arch/*/kernel/cpu/cpufreq/* | grep "^[fd]"
or from linux kernel version 3.2:
/sbin/modinfo /lib/modules/$(uname -r)/kernel/drivers/cpufreq/* | grep "^[fd]"
For more information about governors, read cpu-drivers.txt (available in /usr/share/doc/linux-doc-2.6.32/Documentation/cpu-freq/ from the package linux-doc-2.6, you can read the latest version from kernel.org).
GOVERNOR variable from /etc/default/cpufrequtils not taking effect
So, you configured the GOVERNOR variable in /etc/default/cpufrequtils and after reboot you notice by running cpufreq-info that the active governor is still "ondemand".
This may happen if you have laptop-mode-tools installed. laptop-mode configures the active governor via the following variables: BATT_CPU_GOVERNOR, LM_AC_CPU_GOVERNOR, NOLM_AC_CPU_GOVERNOR. You can override them to your liking in /etc/laptop-mode/laptop-mode.conf:
BATT_CPU_GOVERNOR=powersave LM_AC_CPU_GOVERNOR=conservative NOLM_AC_CPU_GOVERNOR=ondemand
If you use laptop-mode to set the governor, you can disable /etc/init.d/cpufrequtils from starting at boot to save a few miliseconds:
update-rc.d -f cpufrequtils remove
The documentation in /usr/share/doc/linux-doc-2.6.32/Documentation/cpu-freq/