RSS



CPU Scaling, Ubuntu, battery life and you - how to scale your CPU

Wed, Jan 16, 2008

ArsGeek, Linux, Technology, Ubuntu, howto

Talk about it in our Forums

CPU Scaling is a feature built into most modern (mobile) CPUs that allows them to scale up or down in how fast they run and how much energy they suck down based on demand. If you have a fairly modern mobile computer there’s a very good chance that your CPU(s) can handle frequency scaling.

Why should you care? Well, you can control this to tell you computer how much power and how fast it should allow it’s CPU(s) to operate. This can save some energy and thus battery life at the expense of a little performance – which is great for extending the use time of your laptop when it’s unplugged.

Can your CPU(s) handle scaling? There’s an easy way to find out. Open up a terminal session (Applications -> Accessories ->Terminal) and type or paste the following into it:

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

On my machine I get back

1667000 1333000 1000000

Those are in Hertz, so my machine is capable of 1.66Ghz, 1.33Ghz and 1.00 Ghz.

Now that you know your CPU(s) can handle scaling, let’s see what modes are available. In the terminal, type or paste:

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

Again, I get:

powersave ondemand userspace conservative performance

Powersave will keep the CPU constantly at the lowest frequency. Ondemand will set the CPU at the lowest frequency (in my case, 1.00Ghz) until use of the CPU increases, then it will automatically bump it up to the highest frequency (with me, 1.66Ghz). Userspace means that a different program will be used to control the CPU’s scaling. Conservative is where your CPU will go up as needed, starting at the lowest frequency, and then bumping up to the next available until it maxes out. Performance simply sets the CPU(s) at the highest available frequency and keeps it there.

The lower your frequency, the less power you use. So, if you’re bent on extending your battery life to the max, you’d want to keep your CPU(s) at their lowest frequency – but you’ll do this at the expense of computing power. In my case my 1.66Ghz processors would effectively be 1.00Ghz processors.

Now, how do you actively control this? It’s fairly easy. Right click on an empty space in your taskbar (where your applets and such things as Applications, Places and System are located) and choose “Add to panel”. From there, find the CPU Frequency Scaling Monitor. Double click on this and it will appear in your taskbar. Right click on it and choose Properties and you can set various options like have it show your CPU frequency as a frequency (i.e. 1.33Ghz) or as a percentage. If you have multiple CPU’s or a dual/quad core machine you can also choose which CPU to monitor.

cpufreq1.png

To configure this applet to actually allow you to control how your CPU(s) scale, you’ll have to had back to the terminal.

Type this:

sudo dpkg-reconfigure gnome-applets

cpuscale2.png

cpuscaling3.pngThis will throw up a nifty blue screen asking you to say Yes. Do so. Then it will ask if you want to install cpufreq-selector with SUID root. Say yes. Once you’ve done this, go back to your CPU Frequency Scaling Monitor in your taskbar and left click it. You should now be presented with a bunch of options from which you can choose the one you want. You can also directly set the frequency at which your CPU(s) will run at, which can be handy if you want to scale up or down for a short bit and then manually change it again.

As you can see, I’ve got mine set to Ondemand, allowing the frequency to scale up through three different settings (1 GHz, 1.33 GHz or 1.66 GHz) as needed.

While this will take effect immediately, it will only be in effect until you reboot at which time your default settings will come back. To change the default head back into your terminal and type:

gconf-editor

From there head to apps -> gnome-power-manager -> cpufreq. Find the settings policy_ac and policy_battery and change them to whichever setting you want for the default.

cpuscaling4.png

For those with multiple cores or processors who happen to be a bit needy in the info department (like myself) you can add an applet for each CPU. Just add as many applets as you have CPUs and then right click on them, choose Preferences and use the drop down to choose which CPU that particular applet is monitoring.

Now you know a lot more about CPU Frequency Scaling then you may have when you started reading this article and you know how to set it on your computer.

With kudos to thebert and the Ubuntu forums.

Technorati Tags: , , , , , , ,

Click the icon, share the link:
  • Digg
  • del.icio.us
  • MisterWong
  • Furl
  • Reddit
  • Technorati
  • BlinkList
  • feedmelinks
  • PopCurrent
  • Blogosphere News
  • Facebook
  • Fark
  • Mixx
  • Slashdot

This post was written by:

arsgeek - who has written 1980 posts on ArsGeek.


Contact the author

18 Comments For This Post

  1. Nicolas Says:

    Thanks for the article! By the way, Intel as officially stated before that keeping the governor as “on demand” is the most efficient way to use the CPU while reducing the power consumption.

  2. zsolt320i Says:

    Hi,

    i have Amd Athlon 64 3000, and I got the message that my CPU can not be scaled.
    Is it true?
    As I know this CPU-s are scalable.

  3. Bjørnar Says:

    Thanks for this information :D

  4. Kareem Alexandre Says:

    Substantially, the post is really the greatest on this worthw hile topic. I fit in with your conclusions and will thirstily look forward to your future updates. Saying thanks will not just be sufficient, for the fantasti c lucidity in your writing. I will instantly grab your rss feed to stay privy of any updates. Gratifying work and much success in your business dealings!

  5. tech gadget Says:

    Well I was just searching on Google for some videos and songs of my favorite singers and just came across your blog, generally I just visit blogs and retrieve my required information but this time the useful information that you posted in this post compelled me to reply here and appreciate your good work. I just bookmarked your blog :).

  6. Fletcher Mcpharlane Says:

    Very nice, gives me a lot of inspiration being right in the midst of a redesign. It’s all in the details and comment forms are definitely overlooked more often than not. Time well spent on this post.

  7. Wedding centerpiece vases Says:

    Saying thanks will not just be sufficient, for the fantastic lucidity in your writing. I will instantly grab your rss feed to stay privy of any updates.

  8. Wedding centerpiece vases Says:

    Substantially, the post is really the greatest on this worthw hile topic. I fit in with your conclusions and will thirstily look forward to your future updates.

  9. Green screen backgrounds Says:

    I found so many interesting stuff in your blog, especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the enjoyment here! Keep up the excellent work.

  10. Positive pregnancy test Says:

    Substantially, the post is really the greatest on this worthw hile topic. I fit in with your conclusions and will thirstily look forward to your future updates. Good quality content is important but it’s not everything. I’ve seen blogs with bad content, yet they still manage to rank on top for several keywords. Sure, they will certainly bore the reader with bad content.

  11. Wooden fence panels Says:

    By the way, Intel as officially stated before that keeping the governor as “on demand” is the most efficient way to use the CPU while reducing the power consumption. Just wanna say thank you for the information that you have been shared on your site. Simple but very informative. Hoping that you could give more other information about this.

  12. Toy hauler trailers Says:

    Saying thanks will not just be sufficient, for the fantasti c lucidity in your writing. I will instantly grab your rss feed to stay privy of any updates. Thanks for the information on linking.

  13. Motorcycle tank bags Says:

    Thanks for the article! Indeed, as Intel has officially said that keeping the governor as “on demand” is the most efficient way to use the CPU while reducing energy consumption.

  14. FG Says:

    Very nice. Thanks for the post.
    FYI, it appears that in Ubuntu 10.04 the applet -by default- can manage CPU freq and mode.

  15. key ödemeleri sorgulama Says:

    I found so many interesting stuff in your blog, especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the enjoyment here! Keep up the excellent work.

  16. Pole barn prices Says:

    Essentially, the post is actually the largest worthw hile on this topic. I fit their conclusions and thirsty waiting for their future upgrades. Saying thanks not only be enough for fantasti c lucidity in his writing. She immediately takes the RSS feed to keep abreast of any updates. Rewarding work and much success in your business relationships!

  17. Prank call voices Says:

    I found so many interesting stuff in your blog, especially its discussion. I fit their conclusions and thirsty waiting for their future upgrades. Saying thanks not only be enough for fantasti c lucidity in his writing. She immediately takes the RSS feed to keep abreast of any updates.

  18. business opportunity review Says:

    I do a hell of a lot of work on trains so this is a great tutorial for me. Thanks dude!

3 Trackbacks For This Post

  1. Scale your CPU « 0ddn1x: tricks with *nix Says:

    [...] Scale your CPU Filed under: Linux — 0ddn1x @ 2008-01-24 19:54:16 +0000 http://www.arsgeek.com/?p=3344 [...]

  2. Eiriks forfatterblogg :: The Awful Truth: power history of a T61 with Ubuntu 8.04 Says:

    [...] The screendump above shows the power history of my T61 for the two hours and fifteen minutes a full charge lasts. The variation is due to a mixture of writing, watching a movie (that’s the peak around 42 minutes) and talking to a fellow passenger (that’s the trough near the two hour mark). The screen brightness was between the minimum setting and 50 %. Both radio transmitters were switched off, which saves about 3 W. I am also running Powertop and CPU Scaling. [...]

  3. Eric Garrido » Things I found useful today Says:

    [...] This post on CPU scaling reminded me how to root-enable some CPU tools to allow me to easily scale my processor speeds [...]

Leave a Reply