Ubuntu, CPU Scaling, Battery life and You
By arsgeek
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_frequenciesOn my machine I get back 1667000 1333000 1000000Those 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_governorsAgain, I get: powersave ondemand userspace conservative performancePowersave 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.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-appletsThis 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-editorFrom 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.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.Comments
no that is correct... 1000 Hz is 1kHz, and 1 000 000 Hz is 1Ghz...
So his cpu is capable of 1.66Ghz, 1.33Ghz and 1.00 Ghz.
Nope.
1,000,000 Hz is 1 MHz
1,000,000,000 Hz would be 1 GHz
location apps -> gnome-power-manager -> cpufreq does not exist in my jaunty 9.04
@pms:
In jaunty 9.04 last step is not needed because when rebooting, the applet keeps the setting.
Nice article :)
It helped me a lot with the
"sudo dpkg-reconfigure gnome-applets".
Before that I couldn't select the frequency :).
Thanks.
Kaoru: Applet sometimes does not keep the setting.
@Kaoru: Agree with DustWofl, my Jaunty 9.04 sometimes does not keep the setting after reboot. How to fix that?
on Ubuntu 10.4 the CPU goes into performance after reboot.
I guess I'll write a bug request.
I guess I'll write a bug request. :)
You should not request a bug :)
change request?
fix request?
Writing a bug request is not a good idea :)
>>Micha?
I'm sure he meant bug /report/, which would be a good idea.
Any news on this in 10.10?
I can confirm than in 10.10 it always set to Ondemand on boot.
I'm still trying to figure out what exactly this post has to do with Ubuntu...
after i changed my setting, my screen keeps shutting off with no signal..did i do something wrong?
I'm a newbie using xfce rather than gnome. Is this possible in xfce/xubuntu?
apps - gnome-power-manager - cpufreq
apps - gnome-power-manager doesn't have a "cpufreq" entry on my system (even though I do have cpufreq application installed). How can I have my ubuntu64 10.04 LTS (and soon 12.04 LTS) start up with CPU core profiles other than "ondemand" which currently they all are.
Also, when I run a CPU-cycle intensive application (like a freaking benchmark, for example), how long does it take for a core to be upgraded to full speed when it starts out "ondemand"?
SIprefixR 4 years ago
"1667000 1333000 1000000
Those are in HERTZ , so my machine is capable of 1.66Ghz, 1.33Ghz and 1.00 Ghz."
guess you mean kilohertz here.
nice article btw.