CPU Throttling Under Linux

June 12th, 2005

Poking around Slackware, and came across an acpi directory under the pseudo filesystem directory /proc. Outputted a tantalising table full of CPU throttling percentages, so had a Google around about how to change which one is active. The ACPI For Linux documentation gives you all the answers.

Note that I compiled a 2.6.11.2 kernel with ACPI support for my laptop, if you’re on a desktop this would be pointless as you haven’t got a battery to save, but if you’re running on an older kernel version, you may need to use a patch or grab a recent vanilla kernel.

Navigate to the CPU directory. This might be called CPU0 on your system, so if it can’t find the path, just navigate to “processor” and ls out the directories that are available and choose as appropriate:

root@monolith$ cd /proc/acpi/processor/CPU

To see the “files”:
root@monolith$ ls
info limit power throttling

You may notice I’m running as root, if you’re connected up to the internet, or indeed have ever connected up to the internet with your box, you shouldn’t really be doing this, but as I don’t use the internet on Slackware, I find it easier.

Output the table:

root@monolith$ cat throttling
state count: 8
active state: T2
states:
T0: 00%
T1: 12%
*T2: 25%
T3: 37%
T4: 50%
T5: 62%
T6: 75%
T7: 87%

I stupidly assumed 87% to be using 87% of the CPU, I changed it to that and wondered why the system was grinding to a halt. On closer inspection of the docs, I noticed that these are the throttling percentages, i.e. 00% would not be throttling your CPU at all. You change the states by noting their respective number i.e. 3 would be 37%, and issuing the following:

root@monolith$ echo -n x > throttling

Where x is the number you want to throttle it to. When testing pages on my local Apache server I normally put it at about 37% and don’t really notice the performance difference. Obviously should you require performance, just change the throttling to something lower. There are a few daemons you can download that do this for you on the fly, just have a Google around.

Oh, and I now get about an extra 45 minutes to an hour of battery time running under Slack.

2 Responses to “CPU Throttling Under Linux”

  1. orionrobots Says:
    June 22nd, 2005 at 7:54 pm

    While it may not save battery power, could this technique be used to save main powr consumption? And to lower the CPU temperature.

    Possibly - use correctly - you could then (in quiet times) throttle back the CPU, and the fan and get a quieter machine, or when the CPU is hot (on an AMD - Intel P4’s do this internally) throttle it back a little.

    I think I am going to have to research this, and see if the technique works on AMD based machines - I have one which has been overheating a little in our current uk heatwave.

  2. Alex Says:
    June 22nd, 2005 at 10:55 pm

    I’m not sure what the support for ACPI is like with desktops.

    A bigger fan always works wonders with a desktop tower, however if you want to avoid the hassle, I guess having a look at throttling desktops would be interesting.

    An interesting linky-dink:
    Hardware Secrets: Thermal Throttle. This is for P4s, but has an interesting mention about a program that probably works on AMDs.