CPU frequency scaling
Jul. 1st, 2013 04:05 am![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
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.
Enabling
Note: In most cases, this should be enabled automatically during Debian installation.
Install the cpufrequtils package:
aptitude install cpufrequtils
Configuration
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
Install sysfsutils:
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.
Troubleshooting
Check how CPU is configured
Either add "CPU Frequency Scaling Monitor" to your GNOME panel, or 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.
Governor ??
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).
Userland governors
The userland-based governors (cpufreqd, cpudyn, powersaved, powernowd ...) are usually not needed any more.
Drivers
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]"
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
See Also
The documentation in /usr/share/doc/linux-doc-2.6.32/Documentation/cpu-freq/
cpufrequtils's documentation (esp. cpufreq-info(1) and cpufreq-set(1))
powertop is a tool to check what prevents the kernel from going to sleep mode (also read http://www.lesswatts.org/projects/powertop).
External Links
http://kernel.org/doc/Documentation/cpu-freq/cpu-drivers.txt
http://www.pantz.org/software/cpufreq/usingcpufreqonlinux.html
https://wiki.archlinux.org/index.php/CPU_Frequency_Scaling
http://wiki.debian.org/HowTo/CpuFrequencyScaling
-
-
To problem ;
/etc/sysfs.conf
or
/etc/default/cpufrequtils
my lenny;
uname -a
Linux XXX 2.6.26-2-486 #1 Tue Mar 9 17:10:34 UTC 2010 i686 GNU/Linux
cat /etc/init.d/cpufrequtils
or
cat /etc/init.d/cpufrequtils | grep GOVERNOR
See GOVERNOR="ondemand" or whatelse..
Change it to what you want.
/etc/init.d/cpufrequtils restart
http://technowizah.com/2007/01/debian-how-to-cpu-frequency-management.html
-