power management

updated @ 2008-03-07

CPU Frequency Control

First remove this:
apt-get remove powernowd

Then instal sysfsutils, cpufreqd, cpufrequtils:

apt-get install sysfsutils cpufreqd cpufrequtils

Now we'll load the modules:

modprobe speedstep-centrino
modprobe cpufreq_conservative
modprobe cpufreq_ondemand
modprobe cpufreq_powersave
modprobe cpufreq_stats
modprobe cpufreq_userspace

speedstep-centrino is the module for controlling centrino processors, the rest are frequency "governors". We'll test that everything went as expected:

cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors

You should see output similar to

powersave conservative ondemand performance userspace
You can change the current scheme by something like
echo powersave > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
And view the current cpu frequency by
cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq

Now we need to load them at boot time. Add the following lines to the end of /etc/modules

speedstep-centrino
cpufreq_conservative
cpufreq_ondemand
cpufreq_powersave
cpufreq_stats
cpufreq_userspace

Add the following lines to /etc/sysfs.conf

devices/system/cpu/cpu0/cpufreq/scaling_governor=userspace

Where userspace can be changed to another governor type (i.e. conservative, powersave, etc.). You can also add other configuration options that are specific to the governor selected.

Now you can add a cpu applet to your favourite panel [like CPUFreq plugin for the xfce4 panel, or the cpu frequency changing applet in Gnome, as described in this Ubuntu howto. This applet can also change governors]. The ondemand mode seems to work really decently for me. powersave is even more agressive in preserving power, which will result in a clocked down cpu the whole time.

[source]

You can modify your /etc/cpufreqd.conf to your needs. Mine looks like this:

[General]
pidfile=/var/run/cpufreqd.pid
poll_interval=2
verbosity=4
#enable_remote=1
#remote_group=root
[/General]

[Profile]
name=Performance High
minfreq=100%
maxfreq=100%
policy=performance
#exec_post=echo 8 > /proc/acpi/sony/brightness
[/Profile]

[Profile]
name=On Demand High
minfreq=40%
maxfreq=100%
policy=ondemand
[/Profile]

[Profile]
name=Powersave Low
minfreq=40%
maxfreq=40%
policy=powersave
[/Profile]

##
# Basic states
##
# when AC use performance mode
[Rule]
name=AC Rule
ac=on                      # (on/off)
battery_interval=0-100
#profile=Performance High  # enable this if you want the most performance when on AC
profile=On Demand High
[/Rule]

# conservative mode when not AC
[Rule]
name=AC Off
ac=off                     # (on/off)
#exec_post=echo 3 > /proc/acpi/sony/brightness
profile=Powersave Low
[/Rule]

##
# Special Rules
##
# CPU Too hot!
[Rule]
name=CPU Too Hot
acpi_temperature=55-100
cpu_interval=50-100
#profile=Performance Low
profile=Powersave Low
[/Rule]

This removes the rule to run at Performance when on AC [I want my laptop to be cool and quiet, thanks], and the Ondemand scheme takes care of clocking higher and lower when needed.