CPU frequency scaling

This entry was posted by Tuesday, 7 April, 2009
Read the rest of this entry »

Want to do your bit to help save the world?

No real need to have the CPU in your home Linux box burning away flat out! This will idle the CPU at its lowest supported speed, and adjust the clock rate as needed depending on the load. This example is for an P4 based CPU (in my case a Celeron D 2.8GHz) using p4_clockmod

Some of the other common drivers (or modules) are :

AMD K6 processors : powernow_k6
AMD K7 processors (Athlon, Duron, Sempron 32 bits) : powernow_k7
AMD K8 processors (Athlon 64, Turion 64, Sempron 64, Opteron 64) : powernow_k8

Pentium 4, Celeron D, Pentium D, Celeron M : p4_clockmod
Pentium M, Core Duo, Core 2 Duo : speedstep_centrino

There are of course other CPU frequency drivers. In doubt, you can use the generic driver : acpi_cpufreq

Right, down to business (replace p4_clockmod with the driver for your CPU):

apt-get install cpufrequtils sysfsutils
modprobe p4_clockmod
modprobe cpufreq_ondemand
echo ondemand | tee /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

Verify whats happening:

cpufreq-info

cpufrequtils 002: cpufreq-info (C) Dominik Brodowski 2004-2006
Report errors and bugs to linux@brodo.de, please.
analyzing CPU 0:
driver: p4-clockmod
CPUs which need to switch frequency at the same time: 0
hardware limits: 350 MHz – 2.80 GHz
available frequency steps: 350 MHz, 700 MHz, 1.05 GHz, 1.40 GHz, 1.75 GHz, 2.10 GHz, 2.45 GHz, 2.80 GHz
available cpufreq governors: ondemand, performance
current policy: frequency should be within 350 MHz and 2.80 GHz.
The governor “ondemand” may decide which speed to use
within this range.
current CPU frequency is 350 MHz.

Save config/apply at startup:

echo p4_clockmod | tee -a /etc/modules
echo cpufreq_ondemand | tee -a /etc/modules
echo devices/system/cpu/cpu0/cpufreq/scaling_governor = ondemand | tee -a /etc/sysfs.conf

Reboot and run cpufreq-info again to verify. All done! Last-Modified: 2008-12-11 21:19:35

2 Responses to “CPU frequency scaling”

  1. Sgt Debian

    good one! 😀 My Pentium D 2.8mhz was always running at 2.8mhz under Ubuntu 8.04. Now it’s running at 350mhz. Thanks for the instructions 🙂

  2. Sgt Debian

    btw – I have a dual core so I had to type add an extra line for CPU1

    sudo echo devices/system/cpu/cpu1/cpufreq/scaling_governor = ondemand | tee -a /etc/sysfs.conf

    Verified both cores are scaling in real time by adding 2 x CPU Frequency Scaling Monitor applet thingies to the Gnome panel and then launching a few apps to increase load. Thanks again.


Leave a Reply