cpufreqd, How to configure you cpu speed

Written by
Date: 2008-04-13 10:36:30 00:00


cpufreqd is a Linux daemon, that lets you control the speed of your CPU(s), depending on some variables, or also be set manually, you can set it to act dynamically or manually, you can define a lot of profiles and rules, which will control your CPU speed, the variables could be the temperature of your CPU, the amount of charge in your battery if AC is connected or not.

The first thing you need to do is to install the daemon, in Debian / Ubuntu

sudo aptitude install cpufreqd

Then you need to check if the desirable modules are loaded, so enter this command:

sudo lsmod | grep cpufreq

And you should see an output like this:

acpi_cpufreq            9096  0
cpufreq_stats           5120  0
cpufreq_conservative     6888  0
cpufreq_userspace       4128  0
cpufreq_ondemand        8300  2
cpufreq_powersave       1792  0
freq_table              4512  3 acpi_cpufreq,cpufreq_stats,cpufreq_ondemand
processor              31176  2 acpi_cpufreq,thermal

Now you are ready to start creating profiles and rules, when you first install the program, a .conf file is automatically created, and has this content:

# this is a comment
# see CPUFREQD.CONF(5) manpage for a complete reference
#
# Note: ondemand/conservative Profiles are disabled because
#       they are not available on many platforms.

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

#[acpi]
#acpid_socket=/var/run/acpid.socket
#[/acpi]

#[nforce2_atxp1]
#vcore_path=/some/path
#vcore_default=1500
#[/nforce2_atxp1]

#[sensors_plugin]
#sensors_conf=/some/file
#[/sensors_plugin]

[Profile]
name=On Demand High
minfreq=1998000
maxfreq=2331000
policy=ondemand
[/Profile]
#
#[Profile]
#name=On Demand Low
#minfreq=20%
#maxfreq=80%
#policy=ondemand
#[/Profile]

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

[Profile]
name=Powersave High
minfreq=1998000
maxfreq=1998000
policy=powersave
[/Profile]

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

#[Profile]
#name=Conservative High
#minfreq=33%
#maxfreq=100%
#policy=conservative
#[/Profile]
#
#[Profile]
#name=Conservative Low
#minfreq=0%
#maxfreq=66%
#policy=conservative
#[/Profile]

##
# Basic states
##
# when AC use performance mode
#[Rule]
#name=AC Rule
#ac=on                    # (on/off)
#profile=Performance High
#[/Rule]

# stay in performance mode for the first minutes
#[Rule]
#name=AC Off - High Power
#ac=off                   # (on/off)
#battery_interval=70-100
#exec_post=echo 5 > /proc/acpi/sony/brightness
#profile=Performance Low
#[/Rule]

# conservative mode when not AC
#[Rule]
#name=AC Off - Medium Battery
#ac=off                   # (on/off)
#battery_interval=30-70
#exec_post=echo 3 > /proc/acpi/sony/brightness
#profile=Powersave High
#[/Rule]
# conservative mode when not AC
#[Rule]
#name=AC Off - Low Battery
#ac=off                   # (on/off)
#battery_interval=0-30
#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
[/Rule]

# use performance mode if I'm watching a movie
# I don't care for batteries!
# But don't heat too much.
#[Rule]
#name=Movie Watcher
#programs=xine,mplayer,gmplayer
#battery_interval=0-100
#acpi_temperature=0-60
#cpu_interval=0-100
#profile=Performance High
#[/Rule]

This file has three main sections,

[General] [Profile] [Rule]

For a complete and detailed description of each of these read the man page of cpufreqd.conf

man cpufreqd.conf

You can create as many profiles as you want, and then use the rules to apply a specific profile according with the state of your PC hardware, or programs running in a given moment.

It is a good idea to have this [General] section:

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

As you can see, I have enable_remote=1 and remote_group=root this means that I can use the commands cpufreqd-get and cpufreqd-set to check the profiles available, and the running one, also to set manually some specific profile.

To check available profiles enter:

sudo cpufreqd-get

You should see something like this:

Name (#1):      On Demand High
Active on CPU#: 0, 1
Governor:       ondemand
Min freq:       1998000
Max freq:       2331000

Name (#2):      Performance High
Governor:       performance
Min freq:       2331000
Max freq:       2331000

Name (#3):      Performance Low
Governor:       performance
Min freq:       1998000
Max freq:       1998000

Name (#4):      Powersave High
Governor:       powersave
Min freq:       1998000
Max freq:       1998000

Name (#5):      Powersave Low
Governor:       powersave
Min freq:       1998000
Max freq:       1998000

and if you want to see the running one, enter

sudo cpufreqd-get -l

And you will get an output like this:

CPU#0: "On Demand High" ondemand 1998000-2331000

CPU#1: "On Demand High" ondemand 1998000-2331000

Important note

Be sure to check the available frequencies and governors in your hardware, to do that enter this commands:

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

and:

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

Do this for every availabe CPU you may have, and use only those frequencies and governors in your profiles.