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

From ThinkWiki
Jump to: navigation, search
(using the sys interface with scaling gouvernors)
Line 44: Line 44:
 
:{{cmdresult|cpu MHz        : 976.152}}
 
:{{cmdresult|cpu MHz        : 976.152}}
  
 
+
===using scaling gouvernors===
 
 
====using the sys interface with scaling gouvernors====
 
 
 
 
You can compile the scaling gouvernours into your kernel or compile it as module. You'll find the gouvernors with 'make menuconfig' here:
 
You can compile the scaling gouvernours into your kernel or compile it as module. You'll find the gouvernors with 'make menuconfig' here:
: Power managemant options (ACPI, APM)  --->
+
: <code>Power managemant options (ACPI, APM)  ---></code>
:: CPU Frequency scaling  --->
+
:: <code>CPU Frequency scaling  ---></code>
  
  
If the new kernel is booted, you can see with (as root)
+
After booting the new kernel is booted, 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}}
what gouvernors are available.
 
  
*A Short Overview over the available gouvernors:
+
A Short Overview over the available governors:
*# ondemand
+
# ondemand
*#* This driver is a dynamic cpufreq policy governor. It changes Frequenzy based on the processor load.
+
#* This driver is a dynamic cpufreq policy governor. It changes Frequenzy based on the processor load.
*# conservative
+
# conservative
*#* New since 2.6.12. Similar to ''ondemand''. Optimized for battery powered environments and AMD64.
+
#* New since 2.6.12. Similar to ''ondemand''. Optimized for battery powered environments and AMD64.
*# powersafe
+
# powersafe
*#* Like the name says, your battery would choose this one ;). It sets the Frequency always to the lowest available.
+
#* Like the name says, your battery would choose this one ;). It sets the Frequency always to the lowest available.
*# userspace
+
# userspace
*#* You have to choose this one, if other programs (see below) should manage your CPU Frequency.
+
#* You have to choose this one, if other programs (see below) should manage your CPU Frequency.
*# performance
+
# performance
*#* This gouvernour sets your Frequency always to the highest available.
+
#* This gouvernour sets your Frequency always to the highest available.
  
Now we set our gouvernor:
+
Now we set our governor:
 
What is our current governor?
 
What is our current governor?
 
:{{cmdroot|cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor}}
 
:{{cmdroot|cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor}}
 
:{{cmdresult|userspace}}
 
:{{cmdresult|userspace}}
Set new gouvernor and watch if it has changed
+
Set new governor and watch if it has changed
 
:{{cmdroot|echo conservative > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor}}
 
:{{cmdroot|echo conservative > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor}}
 
:{{cmdroot|cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor}}
 
:{{cmdroot|cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor}}
 
:{{cmdresult|conservative}}
 
:{{cmdresult|conservative}}
  
Congrats! Your gouvernor is active.
+
Congrats! Your governor is active.
  
I set the gouvernor in my rc.local.
+
You may set the governor in your rc.local, to make it used on every boot.
  
 
===configuring SpeedStep daemons===
 
===configuring SpeedStep daemons===

Revision as of 10:14, 22 July 2005

general

Linux supports Dynamic Frequency Scaling for ThinkPads with mobile Pentium III, Pentium 4 and Pentium M processors.

configuring the kernel

2.4 kernels

Todo...

2.6 kernels

You need to enable the cpu frequency scaling for your kernel (usually your distros kernel will have this enabled):

CONFIG_CPU_FREQ=y

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

CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
CONFIG_CPU_FREQ_GOV_POWERSAVE=y
CONFIG_CPU_FREQ_GOV_USERSPACE=y

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. It can be enabled with:

CONFIG_CPU_FREQ_GOV_ONDEMAND=y 
  • If you have a Coppermine-piix-smi based Thinkpads like from the A2x, X2x and T2x series you need to enable the speedstep-ich 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

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

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 scaling gouvernors

You can compile the scaling gouvernours into your kernel or compile it as module. You'll find the gouvernors with 'make menuconfig' here:

Power managemant options (ACPI, APM) --->
CPU Frequency scaling --->


After booting the new kernel is booted, 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

A Short Overview over the available governors:

  1. ondemand
    • This driver is a dynamic cpufreq policy governor. It changes Frequenzy based on the processor load.
  2. conservative
    • New since 2.6.12. Similar to ondemand. Optimized for battery powered environments and AMD64.
  3. powersafe
    • Like the name says, your battery would choose this one ;). It sets the Frequency always to the lowest available.
  4. userspace
    • You have to choose this one, if other programs (see below) should manage your CPU Frequency.
  5. performance
    • This gouvernour sets your Frequency always to the highest available.

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.

configuring SpeedStep daemons

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 cpufreq-userspace. Note that since 2.6.10, there is also the ondemand governor in the kernel, which replaces any userspace daemon for cpu scaling and works very well.

There are plenty of userspace frequency scaling daemons available: