Cpufreq is a set of utilities to configure the frequency scaling under Linux. With cpufreq-set you can set the different frequencies for each powerstate. A processor has different powerstates with different frequencies and (sometimes, depending on the type of the processor, even voltages). Each powerstate consume a different amount of power. P0 is the fastest, but most power consuming state Pn (where n is the maximum powerstate, for AMD Phenom/Phenom processors this is 3) is the slowest, but least power consuming state
Whit cpufreq-set you can also set the governor. A governor defines a set of rules that are used to determine when the processor should switch to another powerstate. To view what frequencies and governors are supported by your processor you can use cpufreq-info. Examples of governors are: powersave, ondemand and performance. 'Performance' always uses the fasted powerstate (Pn) and doesn't scale back. 'Powersave' is the most power efficient, but can be a bottleneck for things like videotranscoding because of the fact that it switches quickly back to lower powerstates. 'Ondemand' is the default governor and waits longer before switching back to lower power states. There is also something called a 'userspace governor', where cpufreq lets another (userspace) program decide which powerstate to choose, but that's not recommended because it's usually slower then the existing (kernelspace) governors.
You don't have to configure anything for cpufreq, it should work out-of-the-box with any modern Linux distribution. I use openSUSE 11.2 for example. However, the frequencies of the powerstates are pre-defined. You cannot change these. When you have an AMD Phenom processor you can use k10ctl (and my wrapper script) to set the frequency and voltage for each powerstate. When you combine k10ctl with cpufreqd and cpufreq you can use it to dynamically set the frequency depending on load, temperature, well the things I mentioned above.
About cpufreqd and installation
Cpufreqd is, I quote..
That sounds promising...
I couldn't find a pre-built package wich also was compiled with lm-sensors support, so I downloaded and built one myself.
Be sure you have the latest lm-sensor development package installed. I first used libsensors3, but could get all my temperature sensor to work with cpufreqd. So I recommend libsensors4 eg.
Download the cpufreqd source here. I picked version 2.4.1.
Unpack it and build it (I assume that you have all needed (C++) development packages installed):
./configure --exec-prefix=/usr --prefix=/
If you have a 4 core CPU you can use make -j4 to speed up the build process (or -j2 for two cores).
You can start cpufreqd with:
To make it start on boot:
To debug you can use:
The configuration file of cpufreqd can be found in /etc/cpufreqd.conf. The configuration file contains both profiles and rules. A profile chooses what governor is used and which CPU speeds are allowed. A rule defines on what conditions a specific profile should be used. Examples of supported conditions:
Battery level of your laptop's battery
If your laptop is connected to AC power or not
Temperature of your CPU or motherboard
Fanspeed of one the connected fans
CPU load (of 1 core or CPU or over all cores)
If a specific process is started
You can also start scripts when a profile is selected and that comes in handy if you want to change the frequency and voltage with k10ctl. Furthermore you can set a lot of parameters for the governors used, you can even set the frequency of your nvidia chip. Checkout man cpufreqd.conf for all the possible options.
Putting it al together, I came up with the state diagram below.
The state in this diagram is what I call 'meta powerstates':
When there isn't much to do for the CPU, the 'Power Save' state will be active wich uses low frequencies chosen by the 'ondemand' governor.
When there is some load, the 'Allround' state is active with higher frequency, also chosen by the 'ondemand' governor
When mencoder or ffmpeg is running, the 'Turbo' state is active which overclocks the CPU a little and uses the 'performance' governor to select P0
When the CPU starts to overheat the 'Cooling Down' state is active. The maximum operating temperature of my 965 BE processor is specced at 62°C, but in diverse fora I read it's recommended to keep it below 55°C. The Cooling Down state uses the same settings as the 'Power Save' state but also sends me an E-mail to notify me.
A long story short, here is my /etc/cpufreqd.conf:
# Cooling Down period when CPU is to hot
exec_post=/usr/bin/cpufreq-all -g performance
name=Turbo On Demand
# Special Rules
# Thermal protection
# AMD Phenom II C3 max temp specced at 62C, preferred to keep it below 55C for
# stability reasons.
name=CPU Too Hot
# Movie transcoding
profile=Turbo On Demand
# Default profile
In this configuration file I use different scripts. I don't put these scripts here for your copy-and-paste convenience, because they can damage your CPU (but if your are curious, you can check this article):
k10_turbo which uses k10ctl to define these powerstates: P0: 3.8GHz, P1: 2.8GHz, P2: 2.0 GHz, P1: 1.0 GHz
k10_allround which uses k10ctl to define these powerstates: P0: 3.2GHz, P1: 2.8GHz, P2: 2.0 GHz, P1: 1.0 GHz
k10_powersave which uses k10ctl to define these powerstates: P0: 3.2GHz, P1: 2.8GHz, P2: 2.0 GHz, P1: 1.0 GHz
notify which sends me an email
If you are having problems with reading sensor information correctly, check out the /etc/sensors.conf or /etc/sensors.conf file. It is possible that two sensors have the same name. In the configuration file you can find examples on how to rename a sensor. For example, the renaming the CPU sensor of the 965 BE, add these lines to the end of the file:
label temp1 "cputemp"
Last update notes
Latest scripts can be found here, no support
Was this article useful to you? Please help me by using the toolbar below to tweet the article, give it an eKudo or add it to Hyves, Facebook, Delicous, Digg or another site. Thanks!
Comments on this articleThere is 1 comment
chip "it87-*" "it8712-*" "it8716-*" "it8718-*" "it8720-*"
label in8 "Vbat"
Then followed to a different chip. I've tried to add
label temp1 "CPU0 Temp"
label temp2 "CPU1 Temp"
that I just copied from other chips, but cpufreqd kept showing a phoney static 30C average temperature for some reason. I've tried also to change "it87-*" for "it87*", but had not effect either (not the desired one at least).
I have temperature readings via KDE's "system monitor" though. I've also changed the original cpufreqd.conf with many many variations besides the defaults, "acpi_temperature=", from yours "sensor=coretemp:" to "sensor=" many other things like temp1, coretemp-isa-0000, in8, Vbat, temp1, etc.
Any suggestions? Many thanks.