Difference between revisions of "How to make use of Dynamic Frequency Scaling"

From ThinkWiki
Jump to: navigation, search
m (add mention of conservative to the daemons note)
(Troubleshooting: add link to Problem with CPU frequency scaling)
 
(59 intermediate revisions by 31 users not shown)
Line 1: Line 1:
 
==General==
 
==General==
 
Linux supports dynamic frequency scaling for systems with the following processors:
 
Linux supports dynamic frequency scaling for systems with the following processors:
 
+
*[[Intel Mobile Pentium III]]
*Mobile Pentium III
+
*[[Intel Mobile Pentium III-M]]
*Pentium 4
+
*[[Intel Mobile Pentium 4]]
*Pentium M
+
*[[Intel Mobile Pentium 4-M]]
 +
*[[Intel Pentium M (Banias)]]
 +
*[[Intel Pentium M (Dothan)]]
 +
*[[Intel Core Solo (Yonah)]]
 +
*[[Intel Core Duo (Yonah)]]
 +
*[[Intel Core 2 Duo]]
 
*Mobile Athlon
 
*Mobile Athlon
 
*AMD64
 
*AMD64
 
*Opteron
 
*Opteron
 +
*Via C3
 +
*Via C7
  
==Debian notes==
+
==Configuring the Kernel==
Instead of compiling your own kernel, you can use the  {{Debian}} "stock" kernel. In Unstable/SID the 2.6.12 kernel image with an {{path|/etc/modules}} file that includes:
 
  
battery
 
ac
 
thermal
 
processor
 
acpi-cpufreq
 
cpufreq-userspace
 
  
With the powernowd package and you should be setup.
+
===2.6 Kernels===
 +
You need to enable the CPU frequency scaling for your kernel (usually your distros kernel will have this enabled), under {{kernelconf||||CPU Frequency scaling|Power management options (ACPI, APM)|||}}: {{kernelconf|CONFIG_CPU_FREQ|<*>|||||}}
  
===Configuring the Kernel===
+
If you own a Dothan processor, you need to enable Enhanced SpeedStep functionalities.
====2.4 Kernels====
+
:{{kernelconf|CONFIG_X86_SPEEDSTEP_CENTRINO|<*>|||||}}
There were various frequency scaling implementations in the 2.4 series of kernels. They all were preliminary and a standard was rised with the introduction of the sysfs filesystem in 2.6 kernels. It is recommended to use a 2.6 kernel, if possible.
 
  
====2.6 Kernels====
+
Alternatively, there seems to be some advocacy of a switch over to
You need to enable the cpu frequency scaling for your kernel (usually your distros kernel will have this enabled):
+
:{{kernelconf|CONFIG_X86_ACPI_CPUFREQ|<*>|||||}}
:{{kernelconf|CONFIG_CPU_FREQ|<*>|||||}}
+
for controlling speedstep technology. Apparently this newer kernel option is more aware of acpi powersaving that's done in the BIOS. In any case, both {{kernelconf|CONFIG_X86_SPEEDSTEP_CENTRINO|<*>|||||}} and {{kernelconf|CCONFIG_X86_ACPI_CPUFREQ|<*>|||||}} were found to work on a Menrom (Core 2).
  
You need to enable governors, if not already done in your distros default kernel:
+
You also need to enable governors, if not already done in your distros default kernel:
 
:{{kernelconf|CONFIG_CPU_FREQ_GOV_PERFORMANCE|<*>|||||}}
 
:{{kernelconf|CONFIG_CPU_FREQ_GOV_PERFORMANCE|<*>|||||}}
 +
 +
The '''performance''' CPU governor lets your CPU frequency always to the highest available.
 +
 
:{{kernelconf|CONFIG_CPU_FREQ_GOV_POWERSAVE|<*>|||||}}
 
:{{kernelconf|CONFIG_CPU_FREQ_GOV_POWERSAVE|<*>|||||}}
 +
 +
The '''powersave''' governor sets the frequency to the lowest available. That's not the best choice for battery lifetime on modern Intel CPU, though (see above).
 +
 
:{{kernelconf|CONFIG_CPU_FREQ_GOV_USERSPACE|<*>|||||}}
 
:{{kernelconf|CONFIG_CPU_FREQ_GOV_USERSPACE|<*>|||||}}
  
Since 2.6.10 there is the ondemand governor that does cpu frequency scaling in kernel so you dont need userspace programs like powernowd etc.
+
The '''userspace''' governor allows you to set the frequency manually, unlike the others. Some [[#Using Frequency Scaling Daemons|frequency scaling daemons]] require this governor to operate correctly. This is typically the recommended option with older processors like A30p's pIIIm-1200.
It can be enabled with:
+
 
 
:{{kernelconf|CONFIG_CPU_FREQ_GOV_ONDEMAND|<*>|||||}}
 
:{{kernelconf|CONFIG_CPU_FREQ_GOV_ONDEMAND|<*>|||||}}
 +
:{{kernelconf|CONFIG_CPU_FREQ_GOV_CONSERVATIVE|<*>|||||}}
 +
 +
The '''ondemand''' (available since 2.6.10) and '''conservative''' (since 2.6.12) are governors based on in kernel implementations of CPU scaling algorithms: they scale the CPU frequencies according to the needs (like does the userspace frequency scaling daemons, but in kernel). They differs in the way they scale up and down. The ondemand governor switches to the highest frequency immediately when there is load, while the conservative governor increases frequency step by step. Likewise they behave the other way round for stepping down frequency when the CPU is idle. The conservative governor is good for battery powered environments on AMD64 (but may not work on older ThinkPads like the T21). Ondemand may not work on older laptops without Enhanced SpeedStep due to [http://lists.debian.org/debian-powerpc/2005/05/msg00542.html latency reasons]. Anyway, for recent enough Intel CPU, ondemand is the one recommended for power efficiency (over userspace, and even over "powersave") by the Intel's kernel developer Arjan van de Ven (see [http://www.bughost.org/pipermail/power/2007-May/000166.html], [http://www.bughost.org/pipermail/power/2007-May/000073.html], [http://www.bughost.org/pipermail/power/2007-May/000071.html])
 +
 +
=== 2.6 doing it with modules ===
 +
With the Debian flavour of 2.6.21 and possibly earlier versions as well as other distros, all of the above kernel options are compiled as modules out of the box. You'll have to load them yourself to get speedstep functionality. This can be done simply enough in an /etc/modules file with the lines
 +
<pre>
 +
acpi-cpufreq
 +
cpufreq_ondemand
 +
cpufreq_userspace
 +
cpufreq_conservative
 +
cpufreq_powersave
 +
</pre>
 +
of course, this is a bit excessive if you're only going to use one governor (see below), you only need to load the modules for the governor(s) you are going to use. It seems that "performance" is not a loadable module in my case. Probably because it's built into the kernel as the default. Finally if you're a fan of useless statistics, you can load cpufreq_stats so that you can see how long your processor spends in each state and how many times it transitions with
 +
<pre>
 +
cat /sys/devices/system/cpu/cpu0/cpufreq/stats/total_trans
 +
cat /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state
 +
</pre>
  
Since 2.6.12 there is the conservative governor that works like the ondemand governor, but is recommended for laptops and AMD64:
+
{{NOTE| "acpi-cpufreq" does not work on a T43. Use the module called "speedstep-centrino" instead!<br><br>
:{{kernelconf|CONFIG_CPU_FREQ_GOV_CONSERVATIVE|<*>|||||}}
+
The code for "speedstep-centrino" was added to "acpi-cpufreq" and set for depreciation in kernel 2.6.20}}
 +
 
 +
With kernel >=2.6.31, possibly some versions below that, different CPUFreq processor drivers are added.
 +
* "powernow-k8" is the frequency scaling module for '''AMD''' processors and
 +
* "acpi-cpufreq" looks like the right choose for '''INTEL''' processors, though there is a more aggressive method for P4 and XEON processors called
 +
* "p4-clockmod".  But the last can cause slowdowns and latencies, so you really should read your kernels Handbook Documentation/cpu-freq/ on this.
  
 
==Using the Sys Interface==
 
==Using the Sys Interface==
 
 
The files in {{path|/sys/devices/system/cpu/cpu0/cpufreq/}} provide information and a means of controlling the frequency scaling subsystem.
 
The files in {{path|/sys/devices/system/cpu/cpu0/cpufreq/}} provide information and a means of controlling the frequency scaling subsystem.
 
Seed values are given in Khz. You need to be root to access the /sys filesystem.
 
Seed values are given in Khz. You need to be root to access the /sys filesystem.
Line 61: Line 89:
  
 
==Using Frequency Scaling Governors==
 
==Using Frequency Scaling Governors==
You can compile the scaling governors into your kernel or compile it as module. You'll find the governors with 'make menuconfig' here:
+
You can get a list of available governors with (as root):
:{{kernelconf||||CPU Frequency scaling|Power management options (ACPI, APM)|||}}
 
 
 
After booting the new kernel you can get a list of available governors with (as root):
 
 
:{{cmdroot|cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors}}
 
:{{cmdroot|cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors}}
 
:{{cmdresult|conservative ondemand powersave userspace performance}}
 
:{{cmdresult|conservative ondemand powersave userspace performance}}
  
A Short Overview over the available governors:
+
Note: If the governors are compiled as modules, load them first:
:;ondemand
+
:{{cmdroot|modprobe cpufreq_performance cpufreq_ondemand cpufreq_conservative cpufreq_powersave cpufreq_userspace}}
::This driver is a dynamic cpufreq policy governor. It changes frequency based on the processor load and may not work on older laptops without Enhanced SpeedStep.
 
:;conservative
 
::New since 2.6.12. Similar to ''ondemand''. Optimized for battery powered environments and AMD64. Again, this governor may not work on older ThinkPads like the T21.
 
:;powersave
 
::Like the name says, your battery would choose this one ;). It sets the Frequency always to the lowest available.
 
:;userspace
 
::You have to choose this one, if a [[#Using Frequency Scaling Daemons|frequency scaling daemon]] should manage your CPU frequency or you want to do it manually.
 
:;performance
 
::This governor sets your Frequency always to the highest available.
 
  
 
Now we set our governor:
 
Now we set our governor:
Line 93: Line 109:
 
You may set the governor in your rc.local, to make it used on every boot.
 
You may set the governor in your rc.local, to make it used on every boot.
  
Debian has no rc.local, so read [http://www.debian.org/doc/FAQ/ch-customizing.en.html#s-custombootscripts this] and [http://www.debian.org/doc/FAQ/ch-customizing.en.html#s-booting this].
+
==Using Frequency Scaling Daemons==
 +
Frequency Scaling Daemons adapt the frequency policy to different situations. A typical configuration would be to use the ondemand governor running off batteries and performance otherwise, or combining powersave with conservative on laptops with heat problems. More sophisticated setups adapt to battery level, CPU temperature or even running programs. Some daemons are able to control other power management features like hard disks or graphic cards.
  
A better alternative for Debian than modifying bootscripts, is to install the [http://packages.debian.org/cgi-bin/search_packages.pl?searchon=names&version=all&exact=1&keywords=sysfsutils sysfsutils package]. Then edit /etc/sysfs.conf (as root), where you can setup values to sysfs entries that you want to be modified automatically on boot.
+
{{NOTE|Daemons are optional. If you don't plan to change policies depending on the situation, you don't need one and you can stick to the <tt>ondemand</tt> or <tt>conservative</tt> frequency scaling governors, available in kernels after 2.6.10 or 2.6.12 respectively. See [[#Using Frequency Scaling Governors|above]]. They require less configuration and have generally been experienced to flawlessly adapt to the situations at hand.}}
 
 
==Using Frequency Scaling Daemons==
 
{{NOTE|It is recommended to use the ondemand or conservative frequency scaling governors, available in kernels after 2.6.10 or 2.6.12 respectively. See [[#Using Frequency Scaling Governors|above]]. If you do this you do not need a frequency scaling daemon}}
 
  
Don't forget to enable the userspace governor to have a userspace daemon do the frequency scaling. If it is built as module, load it as <tt>cpufreq-userspace</tt>.
+
Some daemons use the kernel governors (see above), others implement the functionality on their own. In the latter case you have to enable the userspace governor. If it is built as module, load it as <tt>cpufreq-userspace</tt>.
  
 
There are plenty of userspace frequency scaling daemons available:
 
There are plenty of userspace frequency scaling daemons available:
  
 +
*[[How to configure cpudynd | cpudynd]]
 
*[[How to configure cpufreqd | cpufreqd]]
 
*[[How to configure cpufreqd | cpufreqd]]
*[[How to configure cpudynd | cpudynd]]
+
*[[How to use cpufrequtils | cpufrequtils]]
 +
*[[How to configure powernowd | powernowd]]
 +
*[[How to configure powersaved | powersaved]]
 
*[[How to configure speedfreqd | speedfreqd]]
 
*[[How to configure speedfreqd | speedfreqd]]
*[[How to configure powersaved | powersaved]]
+
*[[laptop-mode-tools]] can also be configured to switch governors when the laptop is plugged in and unplugged
*[[How to configure powernowd | powernowd]]
+
 
*[[How to use cpufrequtils | cpufrequtils]]
+
==Debian notes==
 +
Instead of compiling your own kernel, you can use the {{Debian}} "stock" kernel. In Debian/Etch the 2.6.18 kernel image with an {{path|/etc/modules}} file that includes:
 +
 
 +
battery
 +
ac
 +
thermal
 +
processor
 +
acpi-cpufreq
 +
cpufreq-userspace
 +
 
 +
With the powernowd package and you should be setup.
 +
 
 +
{{Debian}} Etch now has {{path|rc.local}} (see package initscripts).
 +
 
 +
However, a better alternative for Debian, rather than modifying bootscripts, is to install the [http://packages.debian.org/cgi-bin/search_packages.pl?searchon=names&version=all&exact=1&keywords=sysfsutils sysfsutils package]. Then edit {{path|/etc/sysfs.conf}} (as root), where you can setup values to sysfs entries that you want to be modified automatically on boot.
  
 
==Troubleshooting==
 
==Troubleshooting==
*If you have a Coppermine-piix-smi based Thinkpads like from the A2x, X2x and T2x series you need to enable the <tt>speedstep-smi</tt> driver in the kernel and load it if it's built as module. You might want to look at [[How to get SpeedStep working on Coppermine-piix4-smi based Thinkpads | this page]].
+
*If you have a Coppermine-piix-smi based ThinkPads like from the A2x, X2x and T2x series you need to enable the <tt>speedstep-smi</tt> driver in the kernel and load it if it's built as module. You might want to look at [[How to get SpeedStep working on Coppermine-piix4-smi based ThinkPads | this page]].
  
*If you have a p4-class celeron based Thinkpad like the R40e you might want to look at [[How to get SpeedStep working on P4-class-Celeron based Thinkpads | this page]]
+
*If you have a p4-class celeron based ThinkPad like the R40e you might want to look at [[How to get SpeedStep working on P4-class-Celeron based ThinkPads | this page]]
 +
 
 +
*You may need to set your BIOS to "maximum performance" if you are using Linux to set the CPU speed.  This is necessary to prevent odd behaviour (cpufreq 'freezing' at certain frequencies) with the T4x series.
 +
 
 +
*You will need to have the cpufreq-selector applet installed at SUID root to use the gnome cpufreq applet.  See [http://ubuntu.wordpress.com/2005/11/04/enabling-cpu-frequency-scaling/ this page] for info.
 +
 
 +
*If you have a thinkpad with intel core i3/5/7 cpu, and it always runs at lowest speed, see [[Problem with CPU frequency scaling]]
  
 
==Finetuning voltages and available frequencies==
 
==Finetuning voltages and available frequencies==
 
See [[Pentium M undervolting and underclocking]].
 
See [[Pentium M undervolting and underclocking]].
  
 +
==A note about CPU throttling==
 +
 +
Throttling the CPU through ACPI "T" states is generally useless for power consumption reduction nowadays.  It is an artifact of the past, when there was no clock frequency scaling and ACPI "C" states were mostly not implemented or didn't exist.
 +
 +
Throttling does not decrease clock frequency at all, and it can even increase power consumption in a modern CPU capable of ACPI "C" states, as it can interfere with the CPU reaching the higher C states (such as C2).
 +
 +
On a T43, setting a CPU to a ACPI Throttle state different than T0 (no throttling) can cause it to draw more than 100mW extra power, as it will reach C2 less often.
 +
 +
In case your BIOS offers "cpu power management" and "pci bus power management" disabled by default (that's the case in X40 with the 2.08 BIOS), you should turn them on (or choose "automatic"). Despite what the BIOS online documentation says ("rarely needed"), this is quite useful, since it make the deepests (C3 and C4) ACPI C-states avaibles. On a kernel more with [[dynticks]] (2.6.21 and over), this should save about 2W or more.
 +
 +
==External links==
 +
* [http://kernel.org/pub/linux/kernel/people/lenb/acpi/doc/OLS2006-ondemand-presentation.pdf ''The Ondemand Governor''], Intel Open Source Technology Center (Venkatesh Pallipadi, Alexey Starikovskiy, Len Brown), presentation at Ottawa Linux Symposium, July 19 2006
  
[[Category:600X]] [[Category:A20m]] [[Category:A20p]] [[Category:A21e]] [[Category:A21m]] [[Category:A21p]] [[Category:A22e]] [[Category:A22m]] [[Category:A22p]] [[Category:i1200]] [[Category:i1300]] [[Category:i1620]] [[Category:G40]] [[Category:G41]] [[Category:R30]] [[Category:R31]] [[Category:R32]] [[Category:R40]] [[Category:R40e]] [[Category:R50]] [[Category:R50e]] [[Category:R50p]] [[Category:R51]] [[Category:R52]] [[Category:T20]] [[Category:T21]] [[Category:T22]] [[Category:T23]] [[Category:T30]] [[Category:T40]] [[Category:T40p]] [[Category:T41]] [[Category:T41p]] [[Category:T42]] [[Category:T42p]] [[Category:T43]] [[Category:T43p]] [[Category:X20]] [[Category:X21]] [[Category:X22]] [[Category:X23]] [[Category:X24]] [[Category:X30]] [[Category:X31]] [[Category:X32]] [[Category:X40]] [[Category:X41]] [[Category:X41 Tablet]] [[Category:TransNote]]
+
[[Category:600X]] [[Category:A20m]] [[Category:A20p]] [[Category:A21e]] [[Category:A21m]] [[Category:A21p]] [[Category:A22e]] [[Category:A22m]] [[Category:A22p]] [[Category:A30]] [[Category:A30p]] [[Category:A31]] [[Category:A31p]] [[Category:i1200]] [[Category:i1300]] [[Category:i1620]] [[Category:G40]] [[Category:G41]] [[Category:R30]] [[Category:R31]] [[Category:R32]] [[Category:R40]] [[Category:R40e]] [[Category:R50]] [[Category:R50e]] [[Category:R50p]] [[Category:R51]] [[Category:R52]] [[Category:R60]] [[Category:R60e]] [[Category:T20]] [[Category:T21]] [[Category:T22]] [[Category:T23]] [[Category:T30]] [[Category:T40]] [[Category:T40p]] [[Category:T41]] [[Category:T41p]] [[Category:T42]] [[Category:T42p]] [[Category:T43]] [[Category:T43p]] [[Category:T60]] [[Category:T60p]] [[Category:T61]] [[Category:X20]] [[Category:X21]] [[Category:X22]] [[Category:X23]] [[Category:X24]] [[Category:X30]] [[Category:X31]] [[Category:X32]] [[Category:X40]] [[Category:X41]] [[Category:X41 Tablet]] [[Category:X60]] [[Category:X60s]] [[Category:Z60m]] [[Category:Z60t]] [[Category:Z61t]] [[Category:Z61e]] [[Category:TransNote]]

Latest revision as of 19:20, 10 February 2011

General

Linux supports dynamic frequency scaling for systems with the following processors:

Configuring the Kernel

2.6 Kernels

You need to enable the CPU frequency scaling for your kernel (usually your distros kernel will have this enabled), under Power management options (ACPI, APM) → CPU Frequency scaling → : <*> (CONFIG_CPU_FREQ)

If you own a Dothan processor, you need to enable Enhanced SpeedStep functionalities.

<*> (CONFIG_X86_SPEEDSTEP_CENTRINO)

Alternatively, there seems to be some advocacy of a switch over to

<*> (CONFIG_X86_ACPI_CPUFREQ)

for controlling speedstep technology. Apparently this newer kernel option is more aware of acpi powersaving that's done in the BIOS. In any case, both <*> (CONFIG_X86_SPEEDSTEP_CENTRINO) and <*> (CCONFIG_X86_ACPI_CPUFREQ) were found to work on a Menrom (Core 2).

You also need to enable governors, if not already done in your distros default kernel:

<*> (CONFIG_CPU_FREQ_GOV_PERFORMANCE)

The performance CPU governor lets your CPU frequency always to the highest available.

<*> (CONFIG_CPU_FREQ_GOV_POWERSAVE)

The powersave governor sets the frequency to the lowest available. That's not the best choice for battery lifetime on modern Intel CPU, though (see above).

<*> (CONFIG_CPU_FREQ_GOV_USERSPACE)

The userspace governor allows you to set the frequency manually, unlike the others. Some frequency scaling daemons require this governor to operate correctly. This is typically the recommended option with older processors like A30p's pIIIm-1200.

<*> (CONFIG_CPU_FREQ_GOV_ONDEMAND)
<*> (CONFIG_CPU_FREQ_GOV_CONSERVATIVE)

The ondemand (available since 2.6.10) and conservative (since 2.6.12) are governors based on in kernel implementations of CPU scaling algorithms: they scale the CPU frequencies according to the needs (like does the userspace frequency scaling daemons, but in kernel). They differs in the way they scale up and down. The ondemand governor switches to the highest frequency immediately when there is load, while the conservative governor increases frequency step by step. Likewise they behave the other way round for stepping down frequency when the CPU is idle. The conservative governor is good for battery powered environments on AMD64 (but may not work on older ThinkPads like the T21). Ondemand may not work on older laptops without Enhanced SpeedStep due to latency reasons. Anyway, for recent enough Intel CPU, ondemand is the one recommended for power efficiency (over userspace, and even over "powersave") by the Intel's kernel developer Arjan van de Ven (see [1], [2], [3])

2.6 doing it with modules

With the Debian flavour of 2.6.21 and possibly earlier versions as well as other distros, all of the above kernel options are compiled as modules out of the box. You'll have to load them yourself to get speedstep functionality. This can be done simply enough in an /etc/modules file with the lines

acpi-cpufreq
cpufreq_ondemand
cpufreq_userspace
cpufreq_conservative
cpufreq_powersave

of course, this is a bit excessive if you're only going to use one governor (see below), you only need to load the modules for the governor(s) you are going to use. It seems that "performance" is not a loadable module in my case. Probably because it's built into the kernel as the default. Finally if you're a fan of useless statistics, you can load cpufreq_stats so that you can see how long your processor spends in each state and how many times it transitions with

cat /sys/devices/system/cpu/cpu0/cpufreq/stats/total_trans
cat /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state
NOTE!
"acpi-cpufreq" does not work on a T43. Use the module called "speedstep-centrino" instead!

The code for "speedstep-centrino" was added to "acpi-cpufreq" and set for depreciation in kernel 2.6.20

With kernel >=2.6.31, possibly some versions below that, different CPUFreq processor drivers are added.

  • "powernow-k8" is the frequency scaling module for AMD processors and
  • "acpi-cpufreq" looks like the right choose for INTEL processors, though there is a more aggressive method for P4 and XEON processors called
  • "p4-clockmod". But the last can cause slowdowns and latencies, so you really should read your kernels Handbook Documentation/cpu-freq/ on this.

Using the Sys Interface

The files in /sys/devices/system/cpu/cpu0/cpufreq/ provide information and a means of controlling the frequency scaling subsystem. Seed values are given in Khz. You need to be root to access the /sys filesystem.

Your max speed is at /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq.

# cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq
700000

Your min speed is at /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq.

# cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq
500000

If you are using the userspace governor, you can write to /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed to change the current speed.

# echo 700000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
# cat /proc/cpuinfo
cpu MHz  : 697.252
# echo 900000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
# cat /proc/cpuinfo
cpu MHz  : 976.152

Using Frequency Scaling Governors

You can get a list of available governors with (as root):

# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
conservative ondemand powersave userspace performance

Note: If the governors are compiled as modules, load them first:

# modprobe cpufreq_performance cpufreq_ondemand cpufreq_conservative cpufreq_powersave cpufreq_userspace

Now we set our governor: What is our current governor?

# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
userspace

Set new governor and watch if it has changed

# echo conservative > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
conservative

Congrats! Your governor is active.

You may set the governor in your rc.local, to make it used on every boot.

Using Frequency Scaling Daemons

Frequency Scaling Daemons adapt the frequency policy to different situations. A typical configuration would be to use the ondemand governor running off batteries and performance otherwise, or combining powersave with conservative on laptops with heat problems. More sophisticated setups adapt to battery level, CPU temperature or even running programs. Some daemons are able to control other power management features like hard disks or graphic cards.

NOTE!
Daemons are optional. If you don't plan to change policies depending on the situation, you don't need one and you can stick to the ondemand or conservative frequency scaling governors, available in kernels after 2.6.10 or 2.6.12 respectively. See above. They require less configuration and have generally been experienced to flawlessly adapt to the situations at hand.

Some daemons use the kernel governors (see above), others implement the functionality on their own. In the latter case you have to enable the userspace governor. If it is built as module, load it as cpufreq-userspace.

There are plenty of userspace frequency scaling daemons available:

Debian notes

Instead of compiling your own kernel, you can use the Debian "stock" kernel. In Debian/Etch the 2.6.18 kernel image with an /etc/modules file that includes:

battery
ac
thermal
processor
acpi-cpufreq
cpufreq-userspace

With the powernowd package and you should be setup.

Debian Etch now has rc.local (see package initscripts).

However, a better alternative for Debian, rather than modifying bootscripts, is to install the sysfsutils package. Then edit /etc/sysfs.conf (as root), where you can setup values to sysfs entries that you want to be modified automatically on boot.

Troubleshooting

  • If you have a Coppermine-piix-smi based ThinkPads like from the A2x, X2x and T2x series you need to enable the speedstep-smi driver in the kernel and load it if it's built as module. You might want to look at this page.
  • If you have a p4-class celeron based ThinkPad like the R40e you might want to look at this page
  • You may need to set your BIOS to "maximum performance" if you are using Linux to set the CPU speed. This is necessary to prevent odd behaviour (cpufreq 'freezing' at certain frequencies) with the T4x series.
  • You will need to have the cpufreq-selector applet installed at SUID root to use the gnome cpufreq applet. See this page for info.

Finetuning voltages and available frequencies

See Pentium M undervolting and underclocking.

A note about CPU throttling

Throttling the CPU through ACPI "T" states is generally useless for power consumption reduction nowadays. It is an artifact of the past, when there was no clock frequency scaling and ACPI "C" states were mostly not implemented or didn't exist.

Throttling does not decrease clock frequency at all, and it can even increase power consumption in a modern CPU capable of ACPI "C" states, as it can interfere with the CPU reaching the higher C states (such as C2).

On a T43, setting a CPU to a ACPI Throttle state different than T0 (no throttling) can cause it to draw more than 100mW extra power, as it will reach C2 less often.

In case your BIOS offers "cpu power management" and "pci bus power management" disabled by default (that's the case in X40 with the 2.08 BIOS), you should turn them on (or choose "automatic"). Despite what the BIOS online documentation says ("rarely needed"), this is quite useful, since it make the deepests (C3 and C4) ACPI C-states avaibles. On a kernel more with dynticks (2.6.21 and over), this should save about 2W or more.

External links

  • The Ondemand Governor, Intel Open Source Technology Center (Venkatesh Pallipadi, Alexey Starikovskiy, Len Brown), presentation at Ottawa Linux Symposium, July 19 2006