Difference between revisions of "Extending battery life on X200"

From ThinkWiki
Jump to: navigation, search
(Turning off the wireless radios)
m (Changed markup for external urls to the correct one)
 
(8 intermediate revisions by 3 users not shown)
Line 12: Line 12:
 
* '''Removing packages that create unnecessarily frequent wake up interrupts.'''
 
* '''Removing packages that create unnecessarily frequent wake up interrupts.'''
 
**These interrupts wake up the CPU, preventing it from staying in its most energy efficient state.
 
**These interrupts wake up the CPU, preventing it from staying in its most energy efficient state.
**I used Powertop from [[www.lesswatts.org]] for this task.
+
**I used Powertop from [http://www.lesswatts.org www.lesswatts.org] for this task.
 
* '''Lowering the voltage supplied to the CPU.'''  
 
* '''Lowering the voltage supplied to the CPU.'''  
 
** Lowering CPU voltage does ''not'' impact performance since the clock frequency is unaffected
 
** Lowering CPU voltage does ''not'' impact performance since the clock frequency is unaffected
**I used phc patches and phctools available at [[www.linux-phc.org]] for this task.
+
**I used phc patches and phctools available at [http://www.linux-phc.org www.linux-phc.org] for this task.
 
*'''Turning off radios that are not needed''
 
*'''Turning off radios that are not needed''
**My X200 has 3 wireless radios: Wifi, Blutooth, Broadband wireless
+
**My X200 has 3 wireless radios: Wifi, Bluetooth, Broadband wireless
  
 
== Finding and removing high interrupt packages ==
 
== Finding and removing high interrupt packages ==
Install PowerTOP from [[www.lesswatts.org/projects/powertop/download.php | here]].
+
Install PowerTOP from [http://www.lesswatts.org/projects/powertop/download.php here].
  
 
Run PowerTOP as root (sudo powertop) and look for the packages that come up on top of the interrupt frequency list. These are the packages that wake up the CPU most frequently.
 
Run PowerTOP as root (sudo powertop) and look for the packages that come up on top of the interrupt frequency list. These are the packages that wake up the CPU most frequently.
Line 46: Line 46:
 
== Reducing CPU voltage ==
 
== Reducing CPU voltage ==
 
===Installing phc module patches===
 
===Installing phc module patches===
The phc module patches are available [[www.ubuntuforums.org/showthread.php?t=786402 | here]], make sure you get the version that matches you kernel version. You can easily check by typing uname -r in a console.
+
The phc module patches are available [http://www.ubuntuforums.org/showthread.php?t=786402 here], make sure you get the version that matches you kernel version. You can easily check by typing uname -r in a console.
  
 
You need not compile your own module, check the thread, users have posted already compiled versions of the acpi-cpufreg.ko module for most kernel versions.
 
You need not compile your own module, check the thread, users have posted already compiled versions of the acpi-cpufreg.ko module for most kernel versions.
Line 70: Line 70:
  
 
===Intalling phctools===
 
===Intalling phctools===
Download them [[www.linux-phc.org/ | here]].  
+
Download them [http://www.linux-phc.org/ here].  
  
 
Unpack the package in a directory where you can conveniently access it. Use the install script (install.sh) to enable pctools to run without requiring a password.
 
Unpack the package in a directory where you can conveniently access it. Use the install script (install.sh) to enable pctools to run without requiring a password.
  
Also download [[www.linux-phc.org/viewtopic.php?f=9&t=16 | here]] the update which supports the Core2Duo CPU.
+
Also download [http://www.linux-phc.org/viewtopic.php?f=9&t=16 here] the update which supports the Core2Duo CPU.
  
 
Unpack the archive and copy the file to"inc/libs" within the PHCTool directory (replace the old one).
 
Unpack the archive and copy the file to"inc/libs" within the PHCTool directory (replace the old one).
Line 91: Line 91:
 
DO NOT RUN THIS TEST WITH A CUSTOM PROGRAM TO CONTROL THE FAN, YOU COULD FRY YOUR SYSTEM. FIRST REVERT TO HW CONTROLLED FAN IF YOU MADE ANY CHANGES TO FAN CONTROL.
 
DO NOT RUN THIS TEST WITH A CUSTOM PROGRAM TO CONTROL THE FAN, YOU COULD FRY YOUR SYSTEM. FIRST REVERT TO HW CONTROLLED FAN IF YOU MADE ANY CHANGES TO FAN CONTROL.
  
Check that you are using "ondemand" as the frequency scaling governor. This provided for the lowest power consumption according to Intel. An easy way to do this is to use Frequency Scaling Monitor Gnome panel applet.
+
Check that you are using "ondemand" as the frequency scaling governor. This governor delivers the lowest power consumption according to Intel. An easy way to do this is to use Frequency Scaling Monitor Gnome panel applet.
  
 
Another way is to check:
 
Another way is to check:
Line 101: Line 101:
  
 
On the Info tab, you will see your CPU identified and the available frequencies for this CPU:
 
On the Info tab, you will see your CPU identified and the available frequencies for this CPU:
  2267Mghz 2266Mhz 1600Mhz 800Mhz
+
  2267Mhz 2266Mhz 1600Mhz 800Mhz
  
 
On the Voltage tab you will see the VID and corresponding voltage for each frequency as well as the difference from the default values.  
 
On the Voltage tab you will see the VID and corresponding voltage for each frequency as well as the difference from the default values.  
Line 126: Line 126:
 
One you have found the lowest VID's that your system can safely run with, enter them on phctools Voltages for both CPU0 and CPU1, then go to settings and click "restore VID's on load".
 
One you have found the lowest VID's that your system can safely run with, enter them on phctools Voltages for both CPU0 and CPU1, then go to settings and click "restore VID's on load".
  
All that is left is to make phctools restore your VID's each time you boot. Add the command
+
All that is left is to make phctools restore your VID's each time you boot. Add the command:
 
  yourphcdirectory/phctools.sh background
 
  yourphcdirectory/phctools.sh background
to yours startup applications in System > Sessions. It will automatically start phctools, make it restore your VID's and quit.
+
to your startup applications in System > Sessions. It will automatically start phctools, make it restore your VID's and quit.
 +
 
 +
Note that if you do nothing, the original VID's are automatically reloaded each time you reboot the system.
  
 
==Turning off the wireless radios==
 
==Turning off the wireless radios==
Line 135: Line 137:
  
 
The hidden power hog is the 3G broadband modem (Ericsson F3507g), even when the 3G led is off. To completely shut down power to the modem:
 
The hidden power hog is the 3G broadband modem (Ericsson F3507g), even when the 3G led is off. To completely shut down power to the modem:
  sudo echo 0 /sys/devices/platfom/thinkpad_acpi/wwan_enable
+
  sudo echo 0 > /sys/devices/platform/thinkpad_acpi/wwan_enable
  
 
There are scripts to do this automatically [[Ericsson_F3507g_Mobile_Broadband_Module | here]].
 
There are scripts to do this automatically [[Ericsson_F3507g_Mobile_Broadband_Module | here]].
  
 
[[Category:X200]]
 
[[Category:X200]]
[[Category:HOWTO]]
+
[[Category:HOWTOs]]

Latest revision as of 14:46, 19 May 2012

Overview

I own the beautiful Lenovo X200 and run Ubuntu Intrepid on the machine. Its battery life is significantly lower than that under Windows and many users have reported that it runs hotter than under Windows.

With the changes below and a 9 cell battery I get over 9 hours on an idle system with backlight at the lowest level and wireless radios off. Before the changes I was only getting 5 hours.

The system also runs a lot cooler and I do not need tpfan (sw fan control for the ThinkPad available here), the built-in hw controller falls back to the lower speeds shortly after a CPU load subsides.

Details

The changes fall into 3 categories:

  • Removing packages that create unnecessarily frequent wake up interrupts.
    • These interrupts wake up the CPU, preventing it from staying in its most energy efficient state.
    • I used Powertop from www.lesswatts.org for this task.
  • Lowering the voltage supplied to the CPU.
    • Lowering CPU voltage does not impact performance since the clock frequency is unaffected
    • I used phc patches and phctools available at www.linux-phc.org for this task.
  • 'Turning off radios that are not needed
    • My X200 has 3 wireless radios: Wifi, Bluetooth, Broadband wireless

Finding and removing high interrupt packages

Install PowerTOP from here.

Run PowerTOP as root (sudo powertop) and look for the packages that come up on top of the interrupt frequency list. These are the packages that wake up the CPU most frequently.

In my case the majority of the easily preventable interrupts were from 3 packages:

  • i915, the intel graphics driver
  • SCIM
  • Gnome Power Manager

With the first one accounting for the bulk of the battery life improvement.

The %'s in PowerTOP give you an indication of what to focus on, no need to worry about a 1% problem (unless it is easy to prevent that it), it will not have much impact on your battery life.

Remember that over time these packages will improve and will not need to be removed.

Turning off DRI

Just insert: Option "NoDRI" to the "Device" section in /etc/X11/xorg.conf. This turns off all 3D, so no compiz or other fancy effect. Worth it for me because the impact on battery life is substantial.

Turning off SCIM

I had my system set to accept foreign characters. Going to System > Language Support > Disable support to enter complex characters does the trick.

Turning off Gnome Power Manager

You may decide you cannot live without it, but on my system I disabled Gnome Power Manager from the startup list: System > Sessions > Power Management daemon.

I replaced it with the Gnome Panel Battery Charge Monitor (Add to Panel...) which works well enough for me.

Reducing CPU voltage

Installing phc module patches

The phc module patches are available here, make sure you get the version that matches you kernel version. You can easily check by typing uname -r in a console.

You need not compile your own module, check the thread, users have posted already compiled versions of the acpi-cpufreg.ko module for most kernel versions.

Once you have the apci-cpufreq.ko module, back up the old module:

sudo cp /lib/modules/$(uname -r)/kernel/arch/x86/kernel/cpu/cpufreq/acpi_cpufreq.ko
/lib/modules/$(uname -r)/kernel/arch/x86/kernel/cpu/cpufreq/acpi_cpufreq.ko.bak

Then copy the new module to the right place:

sudo cp acpi_cpufreq.ko    /lib/modules/$(uname -r)/kernel/arch/x86/kernel/cpu/cpufreq

Restart your system and check that you now have voltage controls by typing: more /sys/devices/system/cpu/cpu0/cpufreq/phc_vids

You should see something like:

38 29 23 13 (your values may be different)

These are the voltage index values for the 4 frequencies available on your CPU. They are directly related to the actual voltages, phctools does the computation for you as explained below.

Notes:

  • If you check phc_fids you will see values that do not make sense
more /sys/devices/system/cpu/cpu0/cpufreq/phc_fids

These are supposed to be the available frequency indexes, which are the ratios of CPU frequency to FSB frequency, sometimes called multipliers. There is a bug in the phc patches which affects how the multiplers are reported. This bug does not affect undervolting your CPU.

Intalling phctools

Download them here.

Unpack the package in a directory where you can conveniently access it. Use the install script (install.sh) to enable pctools to run without requiring a password.

Also download here the update which supports the Core2Duo CPU.

Unpack the archive and copy the file to"inc/libs" within the PHCTool directory (replace the old one).

Lastly made sure the module msr is loaded. PhcTool works without it, but having it loaded allows it to display the actual votage fed into your CPU.

sudo modprobe msr

You can make this module load automatically by adding it to the file /etc/modules

Also install the burnMMX application, it is designed to put a heavy load on your system and is necessary to make sure the voltages you choose will work under load:

sudo apt-get install burnMMX

Experimenting with lower voltages

This is the scary part: you will have to crash your system on purpose. I found it to be harmless, but be forewarned that some users have reported that it could damage your system.

DO NOT RUN THIS TEST WITH A CUSTOM PROGRAM TO CONTROL THE FAN, YOU COULD FRY YOUR SYSTEM. FIRST REVERT TO HW CONTROLLED FAN IF YOU MADE ANY CHANGES TO FAN CONTROL.

Check that you are using "ondemand" as the frequency scaling governor. This governor delivers the lowest power consumption according to Intel. An easy way to do this is to use Frequency Scaling Monitor Gnome panel applet.

Another way is to check:

/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

which returns the currently active governor. You can echo a new value as root, it takes effect immediately.

Start phctools:

phctools.sh

On the Info tab, you will see your CPU identified and the available frequencies for this CPU:

2267Mhz 2266Mhz 1600Mhz 800Mhz

On the Voltage tab you will see the VID and corresponding voltage for each frequency as well as the difference from the default values.

The phc patches prevent you from using a value higher than the highest defaults voltage or a value lower than the lowest default voltage even though phctools will let you enter higher and lower values. They will have no effect, so stay within the range defined by the highest and lowest VID value.

The default values are also reloaded each time you restart the system. Do NOT set phctools to "restore VID on load" at this time.

Now the fun begins...

  1. Start burnMMX in a terminal window. WARNING this puts a lot of stress on your sys
  2. Lower the first VID value, 25 should work to get started. Do this for both CPU's (tab on the left for CPU0 and CPU1
  3. Save values
  4. Use your system for a bit and see if it is stable
  5. Lower the first VID value until your system crashes (or stop before if you do not dare).

My threshold was 15, at this VID my system crashes after less than a minute. At this point reboot your system, restart phctools and set the VID for 2267Mhz to the value that crashed + 2. Do this for both CPU's.

Restart and work on the other frequencies, using the Frequency Scaling Monitor applet to force the CPU to the frequency you want to test.

On my system the safe values were:

17 15 13 13

Making the voltages stick

One you have found the lowest VID's that your system can safely run with, enter them on phctools Voltages for both CPU0 and CPU1, then go to settings and click "restore VID's on load".

All that is left is to make phctools restore your VID's each time you boot. Add the command:

yourphcdirectory/phctools.sh background

to your startup applications in System > Sessions. It will automatically start phctools, make it restore your VID's and quit.

Note that if you do nothing, the original VID's are automatically reloaded each time you reboot the system.

Turning off the wireless radios

The X200 has a great feature: a button on the left side to disable all radios. Use it when you do not need wireless. When you need wireless, use FN + F5 to turn on/off Wifi and Blutooth.

The hidden power hog is the 3G broadband modem (Ericsson F3507g), even when the 3G led is off. To completely shut down power to the modem:

sudo echo 0 > /sys/devices/platform/thinkpad_acpi/wwan_enable

There are scripts to do this automatically here.