cpufreq

Synopsis

Configuring FreeBSD 6.x and later to use Intel SpeedStep or AMD PowerNow/Cool'n'Quiet

Intro

After helping several people with this, I decided to set up a small page detailing how to configure your FreeBSD to enable power savings, this is done via the cpufreq kernel module and the powerd program.

cpufreq

To control the cpustate you need to load the cpufreq(4) kernel module, this is done by running /sbin/kldload cpufreq.ko. NOTE: You cannot load kernel modules if in securelevel 1 or above, see below on how to enable the kernel module on the next reboot.

You can check if the module is loaded by using the kldstat utility

Output of kldstat should be something like this.

Id Refs Address    Size     Name
 1    7 0xc0400000 4a4970   kernel
 2    1 0xc08bb000 a504     cpufreq.ko

This will however only work until the next reboot, so you want to add the following line to /etc/loader.conf:

cpufreq_load="YES"

This will allow you to view and set the CPU Frequency manually.

This is done via the following sysctl's:

dev.cpu.n.freq
dev.cpu.n.freq_levels CPU Frequency levels available in MHz/mW 1).

On some systems the latter part may be -1 for undefined.

Sample

Pentium 4 2.8 GHz

$ sysctl dev.cpu.0.freq dev.cpu.0.freq_levels
dev.cpu.0.freq: 1050
dev.cpu.0.freq_levels: 2801/-1 2450/-1 2100/-1 1750/-1 1400/-1 1050/-1 700/-1 350/-1

Setting CPU speed

dev.cpu.0.freq can be used to view and/or set the current CPU speed, to view the cpuspeed just run sysctl dev.cpu.0.freq, to set the speed to something specific use sysctl dev.cpu.0.freq=350 (350 is selected from dev.cpu.0.freq_levels, select something available on your platform.

Using powerd

You can use powerd(8) to control the CPU speed automatically, lets face it - who wants to change the cpu speed manually every time you want to do the sligtest thing on most pc's (this can be good for some solutions however).

insert the following line into /etc/rc.conf 2)

rc.conf
powerd_enable="YES"

Next, run /etc/rc.d/powerd start This will start powerd, you should now see a powerd process running Example:

# ps -ax |grep powerd
 2759  ??  Ss     4:38.18 /usr/sbin/powerd

Verifying the CPU Speed

You can now see the CPU speed constantly changing with the load of the machine by monitoring dev.cpu.n.freq sysctl.

1) milliwatts
2) or /etc/rc.conf.local