Difference between revisions of "How to reduce power consumption"
m (added x61 and x61s) |
(→LCD Backlight/Brightness) |
||
(34 intermediate revisions by 24 users not shown) | |||
Line 15: | Line 15: | ||
the top power offenders, both userland and kernel modules, which prevent the use of CPU power saving mechanisms and sometime suggest | the top power offenders, both userland and kernel modules, which prevent the use of CPU power saving mechanisms and sometime suggest | ||
fixes accordingly. | fixes accordingly. | ||
− | PowerTOP users collected some [http://www. | + | PowerTOP users collected some [http://www.lesswatts.org/projects/powertop/known.php tips & tricks] |
− | and an informative [http://www. | + | and an informative [http://www.lesswatts.org/projects/powertop/faq.php faq]. |
Alternatively (or complementary) to PowerTOP, running <code>strace -p $(pidof yourapp)</code> | Alternatively (or complementary) to PowerTOP, running <code>strace -p $(pidof yourapp)</code> | ||
Line 24: | Line 24: | ||
Beside CPU wakeups, disks spins are also power hungry. To detect what make your disk spinning, | Beside CPU wakeups, disks spins are also power hungry. To detect what make your disk spinning, | ||
− | |||
sysctl vm.block_dump=1 | sysctl vm.block_dump=1 | ||
− | |||
will list all applications causing disks wakeups on the kernel's dmesg. | will list all applications causing disks wakeups on the kernel's dmesg. | ||
Line 35: | Line 33: | ||
==BIOS settings== | ==BIOS settings== | ||
+ | ===Enabling Power Management=== | ||
Some Thinkpad BIOS (like 2.08 BIOS on {{X40}}) offer two very lame options, | Some Thinkpad BIOS (like 2.08 BIOS on {{X40}}) offer two very lame options, | ||
with a very misleading online help (saying "Usually not needed"). That's | with a very misleading online help (saying "Usually not needed"). That's | ||
− | |||
CPU power management: (default disabled) | CPU power management: (default disabled) | ||
PCI bus power management: (default disabled) | PCI bus power management: (default disabled) | ||
− | |||
You should indeed ''enable'' them, else the deepest C3 and C4 ACPI C-states | You should indeed ''enable'' them, else the deepest C3 and C4 ACPI C-states | ||
are disabled. | are disabled. | ||
+ | |||
+ | ===Disabling I/O Ports=== | ||
+ | The BIOS (at least version 3.11 on {{X200}}) can also be used to disable I/O ports, like PCMCIA/CardBus. Although this requires a reboot to change settings, using the BIOS rather than a configuration file will survive distribution changes and may make it easier to remember how to re-enable a port. Disabling these devices can reduce power consumption by several watts. | ||
==CPU== | ==CPU== | ||
Line 79: | Line 79: | ||
reduce power consumption or to help diagnosing consumers: | reduce power consumption or to help diagnosing consumers: | ||
− | |||
# From PowerTOP's FAQ: | # From PowerTOP's FAQ: | ||
CONFIG_NO_HZ | CONFIG_NO_HZ | ||
Line 104: | Line 103: | ||
CONFIG_CPU_IDLE_GOV_LADDER | CONFIG_CPU_IDLE_GOV_LADDER | ||
CONFIG_CPU_IDLE_GOV_MENU | CONFIG_CPU_IDLE_GOV_MENU | ||
− | |||
Those options are already in Fedora Core 7 and Ubuntu Gutsy (not Feisty) default i686 kernels. | Those options are already in Fedora Core 7 and Ubuntu Gutsy (not Feisty) default i686 kernels. | ||
Line 115: | Line 113: | ||
=== Kernel boot and module loading options === | === Kernel boot and module loading options === | ||
− | If you have an Intel chipset | + | If you have an Intel chipset ICH5 or later (cf. lspci output), as in most modern Thinkpads, you should |
be using the integrated HPET timer (saves about 30 CPU wake ups per second). To see if | be using the integrated HPET timer (saves about 30 CPU wake ups per second). To see if | ||
− | hpet is enabled on your laptop : | + | hpet is enabled on your laptop: |
− | |||
grep hpet /proc/timer_list | grep hpet /proc/timer_list | ||
− | |||
If this does not display "Clock Event Device: hpet", then add | If this does not display "Clock Event Device: hpet", then add | ||
− | |||
hpet=force | hpet=force | ||
− | + | ||
+ | {{WARN|The ICH4 does have an HPET, but it is disabled for a good reason: Intel didn't test/validade it! Use of the ICH4 HPET is '''not''' recommended}} | ||
to your kernel boot options (usualy in /boot/grub/menu.lst or lilo.conf). | to your kernel boot options (usualy in /boot/grub/menu.lst or lilo.conf). | ||
Note that "hpet=force" is only available by default in 2.6.24-rc2 and above | Note that "hpet=force" is only available by default in 2.6.24-rc2 and above | ||
(or as a separated patch for 2.6.22 and 2.6.23, see below). | (or as a separated patch for 2.6.22 and 2.6.23, see below). | ||
+ | |||
+ | On modern ThinkPads the HPET timer is automatically detected and enabled. On certain older machines hpet=force is required such as on the following machines: | ||
+ | * {{T30}}, {{T40}}, {{T40p}}, {{T41}}, {{T41p}}, {{T42}} | ||
+ | * {{X22}}, {{X23}}, {{X24}}, {{X30}}, {{X31}}, {{X40}} | ||
+ | * {{A31}} | ||
+ | * {{SL500}} | ||
+ | |||
+ | {{HELP|please add your ThinkPad to the above list, if <nowiki>hpet=force</nowiki> was required}} | ||
===Useful Patches=== | ===Useful Patches=== | ||
Line 175: | Line 179: | ||
AHCI compatible chipset, and use SATA drives. | AHCI compatible chipset, and use SATA drives. | ||
− | |||
echo 5 > /proc/sys/vm/laptop_mode | echo 5 > /proc/sys/vm/laptop_mode | ||
echo 0 > /proc/sys/kernel/nmi_watchdog | echo 0 > /proc/sys/kernel/nmi_watchdog | ||
Line 187: | Line 190: | ||
echo min_power > /sys/class/scsi_host/host0/link_power_management_policy | echo min_power > /sys/class/scsi_host/host0/link_power_management_policy | ||
echo min_power > /sys/class/scsi_host/host1/link_power_management_policy | echo min_power > /sys/class/scsi_host/host1/link_power_management_policy | ||
− | + | echo min_power > /sys/class/scsi_host/host2/link_power_management_policy | |
If you're running a kernel older than 2.6.22 do this. Not needed for kernels 2.6.22 onward: | If you're running a kernel older than 2.6.22 do this. Not needed for kernels 2.6.22 onward: | ||
− | |||
cd /sys/devices/system/cpu/cpu0/cpufreq | cd /sys/devices/system/cpu/cpu0/cpufreq | ||
cat ondemand/sampling_rate_max > ondemand/sampling_rate | cat ondemand/sampling_rate_max > ondemand/sampling_rate | ||
− | |||
==ATA drives== | ==ATA drives== | ||
Line 202: | Line 203: | ||
===Hard Drives=== | ===Hard Drives=== | ||
+ | |||
The files access time update, while mandated by POSIX, is causing lots of | The files access time update, while mandated by POSIX, is causing lots of | ||
− | + | disk write access; even accessing files on disk cache may wake the ATA or USB | |
− | bus. If you don't use this feature, disable it | + | bus. If you don't use this feature, disable it by adding the <tt>relatime</tt> |
+ | option to all relevant lines in the /etc/fstab, for example: | ||
+ | /dev/sda1 / ext3 relatime,errors=remount-ro 0 1 | ||
− | < | + | (On older kernels you may need to use <tt>noatime</tt> instead of <tt>relatime</tt>.) |
− | |||
− | </ | ||
− | The laptop_mode reduce disk usage by | + | Also consider merely using a larger value for the <tt>commit</tt> option. This defines how often changed data is written to the disk (it is cached until then). The default value is 5 seconds. |
+ | |||
+ | See man mount(8) for details on how the <tt>rel/noatime</tt> and <tt>commit</tt> options work. | ||
+ | |||
+ | Use laptop_mode to reduce disk usage by delaying and grouping writes. You should enable | ||
it, at least while on battery. See [[Laptop-mode]] for more details: | it, at least while on battery. See [[Laptop-mode]] for more details: | ||
− | |||
echo 5 > /proc/sys/vm/laptop_mode | echo 5 > /proc/sys/vm/laptop_mode | ||
− | |||
The default kernel dirty page writeback frequency is very conservative. On | The default kernel dirty page writeback frequency is very conservative. On | ||
a laptop running on battery, one might find more appropriate to reduce it: | a laptop running on battery, one might find more appropriate to reduce it: | ||
− | |||
echo 1500 > /proc/sys/vm/dirty_writeback_centisecs | echo 1500 > /proc/sys/vm/dirty_writeback_centisecs | ||
− | |||
Some power saving hard drives features can be activated with hdparm (beware | Some power saving hard drives features can be activated with hdparm (beware | ||
Line 230: | Line 232: | ||
For more details look at [[How to make use of Power Management features]] : | For more details look at [[How to make use of Power Management features]] : | ||
− | |||
hdparm -B 1 -S 12 /dev/sda # and/or any other disk device | hdparm -B 1 -S 12 /dev/sda # and/or any other disk device | ||
− | </code> | + | |
+ | ====SATA Link Power Management==== | ||
+ | On kernels 2.6.24 and new this enables SATA Link Power Management: | ||
+ | echo min_power > /sys/class/scsi_host/host0/link_power_management_policy | ||
+ | echo min_power > /sys/class/scsi_host/host1/link_power_management_policy | ||
+ | echo min_power > /sys/class/scsi_host/host2/link_power_management_policy | ||
+ | |||
+ | Disable it by replacing <code>min_power</code> with <code>max_performance</code>. | ||
+ | |||
+ | Which host-number to use depends on your laptop. It is typically 0 for the main drive, but for example on the T61 the 0 and 1 are for the pata interface used for the optical drive, and the main hard-disk is on host2. | ||
+ | |||
+ | On Ubuntu Hardy Heron with a 2.6.24-16 kernel, a suspend/resume cycle is much quicker if you disable SATA Link Power Management before initiating the suspend. As of Intrepid Ibex and kernel 2.6.27, this should be fixed. ([https://bugs.launchpad.net/linux/+bug/234047 Launchpad bug 234047], [http://bugzilla.kernel.org/show_bug.cgi?id=10817 Kernel bug 10817]) | ||
+ | |||
+ | ====Laptop Mode Tools==== | ||
+ | |||
+ | The [http://samwel.tk/laptop_mode/ Laptop Mode Tools] utility implements many of the above power-saving measures from disks, and some others. | ||
===Optical drive=== | ===Optical drive=== | ||
Line 245: | Line 261: | ||
can stop this polling when on battery: | can stop this polling when on battery: | ||
− | |||
hal-disable-polling --device /dev/scd0 # or whatever your CD drive is | hal-disable-polling --device /dev/scd0 # or whatever your CD drive is | ||
− | |||
start polling again when on ac: | start polling again when on ac: | ||
− | + | ||
hal-disable-polling --enable-polling --device /dev/scd0 # or whatever your CD drive is | hal-disable-polling --enable-polling --device /dev/scd0 # or whatever your CD drive is | ||
− | |||
Line 273: | Line 286: | ||
using xbacklight. ie. to set backlight at half the brightness: | using xbacklight. ie. to set backlight at half the brightness: | ||
− | |||
xbacklight -set 50 | xbacklight -set 50 | ||
− | |||
You should configure the DPMS to shutdown the screen when idle (rather than | You should configure the DPMS to shutdown the screen when idle (rather than | ||
displaying a fancy but power consuming screensaver). ie. to turn off the | displaying a fancy but power consuming screensaver). ie. to turn off the | ||
− | display after | + | display after 5 minutes of idling: |
− | |||
xset +dpms | xset +dpms | ||
xset dpms 0 0 300 | xset dpms 0 0 300 | ||
− | </code> | + | |
+ | ===Screensaver method=== | ||
+ | Alternatively, you can add a screensaver that does nothing but blank the screen and turn off the display. In this example, I'm using Linux Mint MATE 17.2, please adjust the keywords below accordingly. Also, you will need to enable DPMS as above, or as in [[How to make ACPI work#Screen blanking (Standby)]]. | ||
+ | |||
+ | We need to create 2 files, the first one is <code>/usr/share/applications/screensavers/screenoff.desktop</code>: | ||
+ | |||
+ | [Desktop Entry] | ||
+ | Name=Screen off | ||
+ | Comment=Turns the screen off | ||
+ | Exec=/usr/lib/mate-screensaver/screenoff | ||
+ | TryExec=/bin/true | ||
+ | StartupNotify=false | ||
+ | Terminal=false | ||
+ | Type=Application | ||
+ | Categories=Screensaver; | ||
+ | Keywords=MATE;screensaver;dpms; | ||
+ | OnlyShowIn=MATE; | ||
+ | |||
+ | The second one is <code>/usr/lib/mate-screensaver/screenoff</code>, which needs to be executable: | ||
+ | |||
+ | #!/bin/sh | ||
+ | pidof mate-screensaver-preferences | grep -w $PPID && exit 0 | ||
+ | xset q | grep -q "Monitor is On" && xset dpms force off | ||
+ | |||
+ | The <code>Keywords</code> section and the <code>mate-screensaver-preferences</code> should be customized according to your desktop (like Cinnamon, or GNOME, etc). | ||
+ | |||
+ | After creating those files, open the Screensaver preferences dialog and choose the screensaver with the name "Screen off". Now, when the screensaver is activated, the screen will fade to black and backlight will be turned off by DPMS. | ||
==Graphic controllers== | ==Graphic controllers== | ||
Line 294: | Line 330: | ||
the /etc/X11/xorg.conf "Device" of you graphic controller: | the /etc/X11/xorg.conf "Device" of you graphic controller: | ||
− | |||
Option "NoDRI" | Option "NoDRI" | ||
− | |||
Also be sure that DPMS is working: <code>grep DPMS /var/log/Xorg.0.log</code> | Also be sure that DPMS is working: <code>grep DPMS /var/log/Xorg.0.log</code> | ||
Line 305: | Line 339: | ||
as connected but not used outputs) when you're not using it: it's known to consume power. | as connected but not used outputs) when you're not using it: it's known to consume power. | ||
− | |||
xrandr # see all displays listed here, but that you don't actually use and disable them. | xrandr # see all displays listed here, but that you don't actually use and disable them. | ||
− | xrandr --output TV -off # for instance (if "xrandr" above listed a connected output named "TV" that you don't use) | + | xrandr --output TV --off # for instance (if "xrandr" above listed a connected output named "TV" that you don't use) |
− | |||
When you don't have an external monitor plugged, disable CRT and DVI output | When you don't have an external monitor plugged, disable CRT and DVI output | ||
(for some, this can make a difference in power usage) : | (for some, this can make a difference in power usage) : | ||
− | + | ||
echo crt_disable > /proc/acpi/ibm/video | echo crt_disable > /proc/acpi/ibm/video | ||
echo dvi_disable > /proc/acpi/ibm/video | echo dvi_disable > /proc/acpi/ibm/video | ||
− | |||
Some drivers have specials power saving mode, and/or allows underclocking the GPU. See also: | Some drivers have specials power saving mode, and/or allows underclocking the GPU. See also: | ||
Line 326: | Line 357: | ||
plugged (and beside, USB devices tends to suck power on their own), so avoid | plugged (and beside, USB devices tends to suck power on their own), so avoid | ||
using such devices when on battery. To enable it by default, you must add the line | using such devices when on battery. To enable it by default, you must add the line | ||
− | + | ||
− | options usbcore autosuspend=1 | + | options usbcore autosuspend=1 |
− | + | ||
− | to your <tt>/etc/modprobe.conf</tt> or add it to (and create if necessary) the file <tt>/etc/modprobe.d/usbcore</tt> depending on how your distribution organises modprobe | + | to your <tt>/etc/modprobe.conf</tt> or add it to (and create if necessary) the file <tt>/etc/modprobe.d/usbcore</tt> depending on how your distribution organises modprobe configuration. |
If on the other hand, you have <tt>usbcore</tt> built into your kernel, you can add this in the kernel boot options (ie. in grub's menu.lst): | If on the other hand, you have <tt>usbcore</tt> built into your kernel, you can add this in the kernel boot options (ie. in grub's menu.lst): | ||
− | |||
usbcore.autosuspend=1 | usbcore.autosuspend=1 | ||
− | |||
or at runtime, per device, with: | or at runtime, per device, with: | ||
− | + | for i in /sys/bus/usb/devices/*/power/autosuspend; do echo 1 > $i; done | |
− | for i in /sys/bus/usb/devices/ | + | for i in /sys/bus/usb/devices/*/power/level; do echo auto > $i; done |
− | |||
USB 1.1 is worst. It needs polling the bus frequently, hence can't really go | USB 1.1 is worst. It needs polling the bus frequently, hence can't really go | ||
Line 347: | Line 375: | ||
plugged. You'd better remove it when you don't use a 1.1 device: | plugged. You'd better remove it when you don't use a 1.1 device: | ||
− | |||
rmmod uhci_hcd | rmmod uhci_hcd | ||
− | |||
If you don't intend to use any device needing USB 1.1 (unfortunately, the built-in bluetooth and fingerprint-reader are USB 1.1 devices), the USB 1.1 support can also be totally avoided. On Debian and derivatives, just do: | If you don't intend to use any device needing USB 1.1 (unfortunately, the built-in bluetooth and fingerprint-reader are USB 1.1 devices), the USB 1.1 support can also be totally avoided. On Debian and derivatives, just do: | ||
− | |||
echo "blacklist uhci_hcd" >> /etc/modprobe.d/blacklist | echo "blacklist uhci_hcd" >> /etc/modprobe.d/blacklist | ||
− | |||
− | Same for PCMCIA/ | + | ==PCMCIA/CardBus== |
+ | Same for PCMCIA/CardBus. Some users experiences interrupts clouds (sometime up to | ||
several thousands interrupts/second) causing CPU wakeups, thus totally preventing | several thousands interrupts/second) causing CPU wakeups, thus totally preventing | ||
the CPU to reach lower C-states. | the CPU to reach lower C-states. | ||
Line 363: | Line 388: | ||
to restore the system properly, you have to boot without it): | to restore the system properly, you have to boot without it): | ||
− | |||
echo "blacklist pcmcia" >> /etc/modprobe.d/blacklist | echo "blacklist pcmcia" >> /etc/modprobe.d/blacklist | ||
echo "blacklist yenta_socket" >> /etc/modprobe.d/blacklist | echo "blacklist yenta_socket" >> /etc/modprobe.d/blacklist | ||
− | |||
==Sound== | ==Sound== | ||
+ | |||
ALSA has a power saving feature that should be enabled on your kernel | ALSA has a power saving feature that should be enabled on your kernel | ||
(CONFIG_SND_AC97_POWER_SAVE). Note that this low power mode won't trigger in | (CONFIG_SND_AC97_POWER_SAVE). Note that this low power mode won't trigger in | ||
Line 374: | Line 398: | ||
to be activated with: | to be activated with: | ||
− | |||
amixer set Line mute nocap | amixer set Line mute nocap | ||
amixer set Mic mute nocap | amixer set Mic mute nocap | ||
echo Y > /sys/module/snd_ac97_codec/parameters/power_save | echo Y > /sys/module/snd_ac97_codec/parameters/power_save | ||
− | |||
− | + | ||
+ | ===Intel HD Audio=== | ||
+ | |||
+ | If you have Intel HD audio as your onboard sound controller, substitute the following for the last line in the above sequence: | ||
+ | |||
+ | echo Y > /sys/module/snd_hda_intel/parameters/power_save_controller | ||
+ | |||
+ | You also may wish to decrease the sound poweroff timeout to something shorter, like 1 second after last playback: | ||
+ | |||
+ | echo 1 > /sys/module/snd_hda_intel/parameters/power_save | ||
+ | |||
+ | ===Additional Tweaks=== | ||
+ | |||
+ | You can unload all sound related modules when you are on | ||
battery, or mute the sound system (echo mute > /proc/acpi/ibm/volume). | battery, or mute the sound system (echo mute > /proc/acpi/ibm/volume). | ||
Line 390: | Line 425: | ||
To save power, you can kill the Wi-Fi radio when it's not in use: | To save power, you can kill the Wi-Fi radio when it's not in use: | ||
− | |||
echo 1 > /sys/bus/pci/devices/*/rf_kill | echo 1 > /sys/bus/pci/devices/*/rf_kill | ||
− | |||
If you need Wi-Fi, you can also reduce power consumption (at the price of | If you need Wi-Fi, you can also reduce power consumption (at the price of | ||
performances) by activating the power saving modes: | performances) by activating the power saving modes: | ||
− | |||
iwpriv eth1 set_power 5 | iwpriv eth1 set_power 5 | ||
− | |||
For drivers using the new Wi-Fi kernel framework (mac80211/cfg80211), | For drivers using the new Wi-Fi kernel framework (mac80211/cfg80211), | ||
the canonical way to do this is now: | the canonical way to do this is now: | ||
− | |||
for i in /sys/bus/pci/devices/*/power_level ; do echo 5 > $i ; done | for i in /sys/bus/pci/devices/*/power_level ; do echo 5 > $i ; done | ||
− | |||
Most drivers, like ipw2200, that don't use the new mac80211 framework place the | Most drivers, like ipw2200, that don't use the new mac80211 framework place the | ||
Line 415: | Line 444: | ||
is plain active and in use. But this can disabled at module's load time : | is plain active and in use. But this can disabled at module's load time : | ||
− | |||
rmmod ipw2200 | rmmod ipw2200 | ||
modprobe ipw2200 associate=0 | modprobe ipw2200 associate=0 | ||
− | |||
You can fix this setting by placing the following in /etc/modprobe.d/options | You can fix this setting by placing the following in /etc/modprobe.d/options | ||
(Debian/Ubuntu) or in /etc/modprobe.conf (Red Hat/Fedora): | (Debian/Ubuntu) or in /etc/modprobe.conf (Red Hat/Fedora): | ||
− | |||
options ipw2200 associate=0 | options ipw2200 associate=0 | ||
− | |||
Reducing beacon intervals on your Access Point to 1 per second will also | Reducing beacon intervals on your Access Point to 1 per second will also | ||
reduce network card interrupts, therefore power savings. This shouldn't have | reduce network card interrupts, therefore power savings. This shouldn't have | ||
negatives side effects. | negatives side effects. | ||
+ | |||
+ | In recent kernels, the powersaving on the intel ipw3945 has been disabled, as | ||
+ | for some it is unstable. For others it worked just fine. | ||
+ | |||
+ | See [http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.33.y.git;a=blobdiff;f=drivers/net/wireless/iwlwifi/iwl-3945.c;h=e413bd35bc411a1113177f1576538eb0ac26f00c;hp=4609323d8436dc9e22c74be2f1f3cf5e97785cb2;hb=bc45a67079c916a9bd0a95b0b879cc0f259bac6e;hpb=b7bb1756cb6a610cdbac8cfdad9e79bb5670b63b this patch]. You may wish to try changing '.broken_powersave=true' to false, in /usr/src/linux/drivers/net/wireless/iwlwifi/iwl-3945.c if you wish to enable powersave. | ||
See also, to activate power saving on the wireless network card: | See also, to activate power saving on the wireless network card: | ||
Line 439: | Line 469: | ||
because it sucks a lot of power: | because it sucks a lot of power: | ||
− | |||
ethtool -s eth0 wol d | ethtool -s eth0 wol d | ||
− | |||
If you can, try to reduce useless network activity on your ethernet | If you can, try to reduce useless network activity on your ethernet | ||
Line 449: | Line 477: | ||
Forcing 100Mbps full-duplex speed on a gigabit ethernet NIC can also save a lot of power (~1W) on most network workloads. This also reduces components temperature (e.g., [[Thermal Sensors|thermal sensor]] 0xC0 on the {{T43}} cools down by 5 degree between 1000Mbps and 100Mbps, and another 1 degree for 10Mbps). | Forcing 100Mbps full-duplex speed on a gigabit ethernet NIC can also save a lot of power (~1W) on most network workloads. This also reduces components temperature (e.g., [[Thermal Sensors|thermal sensor]] 0xC0 on the {{T43}} cools down by 5 degree between 1000Mbps and 100Mbps, and another 1 degree for 10Mbps). | ||
− | |||
ethtool -s eth0 autoneg off speed 100 | ethtool -s eth0 autoneg off speed 100 | ||
− | |||
Note, however, that if the network device on the other side has auto-negotiation enabled (which is very common) and you turn auto-negotiation off, the other side will assume half-duplex mode and you will experience a significant loss of performance. | Note, however, that if the network device on the other side has auto-negotiation enabled (which is very common) and you turn auto-negotiation off, the other side will assume half-duplex mode and you will experience a significant loss of performance. | ||
Line 459: | Line 485: | ||
bluetooth is not power friendly. | bluetooth is not power friendly. | ||
− | |||
hciconfig hci0 down ; rmmod hci_usb | hciconfig hci0 down ; rmmod hci_usb | ||
echo disable > /proc/acpi/ibm/bluetooth | echo disable > /proc/acpi/ibm/bluetooth | ||
− | |||
==Modem== | ==Modem== | ||
Line 485: | Line 509: | ||
* <code>strace -p $(pidof yourapp)</code> # for all your running applications | * <code>strace -p $(pidof yourapp)</code> # for all your running applications | ||
* <code>powertop</code> | * <code>powertop</code> | ||
+ | * <code>dstat -t -c --power --top-cpu --top-io --top-bio --top-latency --top-cputime</code> | ||
* <code>sysctl vm.block_dump=1</code> # and look at dmesg | * <code>sysctl vm.block_dump=1</code> # and look at dmesg | ||
* <code>ps aux | awk '{print$10,$11}' | sort -n</code> # will list all running softs sorted by used cpu time | * <code>ps aux | awk '{print$10,$11}' | sort -n</code> # will list all running softs sorted by used cpu time |
Latest revision as of 02:23, 28 October 2015
Reducing system power consumption will extend battery life, reduce system temperature and (on some models) reduce system fan noise. Power consumption can be greatly improved from a stock distribution configuration to a fine tuned system. The general rules are :
- Unload drivers for unused devices (ie. USB 1.1, Yenta/PCMCIA, Wireless, IRDA, Bluetooth, ...)
- Reduce polling on devices (drives, USB subsystem, nvram, use SATA AN, ...)
- Reduce hard drive activity
- Reduce LCD brightness to the minimum you can stand
- Reduce CPU wakeups, so it can stay longer in deep power saving c-states
- Make use of every hardware devices availables power saving features (AHCI ALPM, USB autosuspend, Alsa and Wireless powersaving modes, HPET timers, ...)
Contents
- 1 Tools
- 2 BIOS settings
- 3 CPU
- 4 Kernel settings and patches
- 5 ATA drives
- 6 LCD Backlight/Brightness
- 7 Graphic controllers
- 8 USB Subsystem
- 9 PCMCIA/CardBus
- 10 Sound
- 11 Wireless Interface
- 12 Ethernet Controler
- 13 Bluetooth
- 14 Modem
- 15 System Fans
- 16 Misbehaving Userland
- 17 See Also
- 18 External resources
Tools
Arjan van de Ven's PowerTOP utility is a gold mine to improve energy efficiency, but is almost only CPU-oriented. This tool helps to easily detect the top power offenders, both userland and kernel modules, which prevent the use of CPU power saving mechanisms and sometime suggest fixes accordingly. PowerTOP users collected some tips & tricks and an informative faq.
Alternatively (or complementary) to PowerTOP, running strace -p $(pidof yourapp)
for all your favorite or background running applications while they are expected to be
idle, will show the misbehaviors.
Beside CPU wakeups, disks spins are also power hungry. To detect what make your disk spinning,
sysctl vm.block_dump=1
will list all applications causing disks wakeups on the kernel's dmesg. Other useful tools for this purpose are blktrace, iostat and lm-profiler (from laptop-mode-tools suite).
See also #Misbehaving Userland.
BIOS settings
Enabling Power Management
Some Thinkpad BIOS (like 2.08 BIOS on X40) offer two very lame options, with a very misleading online help (saying "Usually not needed"). That's
CPU power management: (default disabled) PCI bus power management: (default disabled)
You should indeed enable them, else the deepest C3 and C4 ACPI C-states are disabled.
Disabling I/O Ports
The BIOS (at least version 3.11 on X200) can also be used to disable I/O ports, like PCMCIA/CardBus. Although this requires a reboot to change settings, using the BIOS rather than a configuration file will survive distribution changes and may make it easier to remember how to re-enable a port. Disabling these devices can reduce power consumption by several watts.
CPU
Look at:
A good thing to keep in mind is that every CPU wakeup, even if it's for a trivial light job, reduce the time the CPU stays on a deep power saving C-state (like C3 or C4). Therefore you should ensure your applications stay really idle when they meant to be idle (track shorts select timeouts in loop, etc. with PowerTOP).
Also note that manually locking the CPU in the lowest P-state (frequency) available is not an efficient way to improve battery lifetime. This will cause the CPU to stay longer in C0 (power hungry C-state) doing hard work when there is something to do, while it could have done this work faster by augmenting the CPU freq, and returned back faster to a deeper, economic, C-state and to a lower frequency (P-state). The best is to let the kernel select the appropriates CPU frequencies by itself with the help of in kernel CPU governors. Have a look at this explanation from Intel's kernel developer Arjan van de Ven.
Kernel settings and patches
General settings
The 2.6.21 kernel brought some very effective changes (like dynticks). Later, 2.6.24-rc2 brought a lot of other power efficiency improvements. If it's not already on your distribution and you value power efficiency, you may think about compiling a recent kernel yourself.
Here are a few options (beside the ACPI and APM related one) that matter to reduce power consumption or to help diagnosing consumers:
# From PowerTOP's FAQ: CONFIG_NO_HZ CONFIG_HIGH_RES_TIMERS CONFIG_HPET CONFIG_HPET_TIMER CONFIG_CPU_FREQ_GOV_ONDEMAND CONFIG_USB_SUSPEND CONFIG_SND_AC97_POWER_SAVE CONFIG_SND_HDA_POWER_SAVE CONFIG_SND_HDA_POWER_SAVE_DEFAULT=3 CONFIG_TIMER_STATS CONFIG_ACPI_BATTERY CONFIG_CPU_FREQ_STAT CONFIG_INOTIFY
# Not from the PowerTOP FAQ: CONFIG_BLK_DEV_IO_TRACE CONFIG_X86_ACPI_CPUFREQ CONFIG_X86_SPEEDSTEP_CENTRINO depreciated as of kernel 2.6.24, use CONFIG_X86_ACPI_CPUFREQ CONFIG_X86_SPEEDSTEP_ICH CONFIG_X86_SPEEDSTEP_SMI CONFIG_CPU_IDLE CONFIG_CPU_IDLE_GOV_LADDER CONFIG_CPU_IDLE_GOV_MENU
Those options are already in Fedora Core 7 and Ubuntu Gutsy (not Feisty) default i686 kernels. PowerTOP FAQ also suggest to disable CONFIG_IRQBALANCE and CONFIG_ACPI_DEBUG.
Also, you need to properly set APM and ACPI. Look at:
Kernel boot and module loading options
If you have an Intel chipset ICH5 or later (cf. lspci output), as in most modern Thinkpads, you should be using the integrated HPET timer (saves about 30 CPU wake ups per second). To see if hpet is enabled on your laptop:
grep hpet /proc/timer_list
If this does not display "Clock Event Device: hpet", then add
hpet=force
to your kernel boot options (usualy in /boot/grub/menu.lst or lilo.conf). Note that "hpet=force" is only available by default in 2.6.24-rc2 and above (or as a separated patch for 2.6.22 and 2.6.23, see below).
On modern ThinkPads the HPET timer is automatically detected and enabled. On certain older machines hpet=force is required such as on the following machines:
Useful Patches
Thomas Gleixner High Resolution Timers (hrt) patchset brings many improvements, like the cpuidle work and Udo A. Steinberg and Venki Pallipadi "force enable HPET" patches (non HPET timers causes about 20-40 CPU wakeups/second, but HPET is often hidden by the BIOS due to Windows XP deficiencies). Those are fully merged in 2.6.24-rc1 vanilla kernel. See http://www.tglx.de/projects/hrtimers/
Kristen Carlson Accardi from Intel has a patchset to turn on "Aggressive Link Power Management" (ALPM) for the AHCI driver (for SATA bus). Also from Accardi, SATA Asynchronous Notification (SATA AN), alows SATA link to notify media insertions (thus avoid hal polling the cdrom). Those patches were merged in 2.6.24-rc2 kernel (AN needs also support in hal to be used). See: http://www.kernel.org/pub/linux/kernel/people/kristen/patches/SATA/alpm/
As of now (2.6.24-rc8), the linux kernel doesn't support PCI Express power management (aka PCIe ASPM, aka PCIe LPM). Shaohua Li from Intel submited a patch on LKML (http://lkml.org/lkml/2008/1/17/544 ) though, and reported it to reduce power consumption by 1.3 watts for a system with three PCIe links.
The HDAPS disk protection systems can reduce battery life. Matthew Garrett provides a patch that prevents hdaps kernel module to generate interrupts when this feature isn't used.
Useful sysctls
The meaning of those settings is explained case by case on the relevant sections of this document. But for convenience sake, we group them here too.
Note that the "ondemand" scaling governor is recommended by Intel developers for energy efficiency: it's expected to be more efficient than the "powersave" governor, or than userspace daemons (like cpufreq-utils, cpufreqd, powernowd...). Look here, here, or here for a kernel developer explanation about "ondemand" being better on modern Intel CPUs.
The "link_power_management_policy" tunable won't be available unless you run a 2.6.24-rc2 or more kernel, or applied Kirsten patchset, have an Intel AHCI compatible chipset, and use SATA drives.
echo 5 > /proc/sys/vm/laptop_mode echo 0 > /proc/sys/kernel/nmi_watchdog echo Y > /sys/module/snd_ac97_codec/parameters/power_save echo 1 > /sys/devices/system/cpu/sched_mc_power_savings echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor echo 1500 > /proc/sys/vm/dirty_writeback_centisecs for i in /sys/bus/usb/devices/*/power/autosuspend; do echo 1 > $i; done # those sysctl's are only available if you have an AHCI compatible SATA # controler and use kernel > 2.6.24-rc2 (or use Kristen ALPM patchset) : echo min_power > /sys/class/scsi_host/host0/link_power_management_policy echo min_power > /sys/class/scsi_host/host1/link_power_management_policy echo min_power > /sys/class/scsi_host/host2/link_power_management_policy
If you're running a kernel older than 2.6.22 do this. Not needed for kernels 2.6.22 onward:
cd /sys/devices/system/cpu/cpu0/cpufreq cat ondemand/sampling_rate_max > ondemand/sampling_rate
ATA drives
Hard drives and CDRom drives spinning is very costly. To improve battery lifetime, you should reduce disks access (or devices polling) the more you can.
Hard Drives
The files access time update, while mandated by POSIX, is causing lots of disk write access; even accessing files on disk cache may wake the ATA or USB bus. If you don't use this feature, disable it by adding the relatime option to all relevant lines in the /etc/fstab, for example:
/dev/sda1 / ext3 relatime,errors=remount-ro 0 1
(On older kernels you may need to use noatime instead of relatime.)
Also consider merely using a larger value for the commit option. This defines how often changed data is written to the disk (it is cached until then). The default value is 5 seconds.
See man mount(8) for details on how the rel/noatime and commit options work.
Use laptop_mode to reduce disk usage by delaying and grouping writes. You should enable it, at least while on battery. See Laptop-mode for more details:
echo 5 > /proc/sys/vm/laptop_mode
The default kernel dirty page writeback frequency is very conservative. On a laptop running on battery, one might find more appropriate to reduce it:
echo 1500 > /proc/sys/vm/dirty_writeback_centisecs
Some power saving hard drives features can be activated with hdparm (beware that "-B 1" may reduce your drive lifetime, if you have lot of intermittent disk activity causing lots of heads load/unloads: so reduce I/O activity first, as explained above, in order to get longer disks idling periods). For more details look at How to make use of Power Management features :
hdparm -B 1 -S 12 /dev/sda # and/or any other disk device
SATA Link Power Management
On kernels 2.6.24 and new this enables SATA Link Power Management:
echo min_power > /sys/class/scsi_host/host0/link_power_management_policy echo min_power > /sys/class/scsi_host/host1/link_power_management_policy echo min_power > /sys/class/scsi_host/host2/link_power_management_policy
Disable it by replacing min_power
with max_performance
.
Which host-number to use depends on your laptop. It is typically 0 for the main drive, but for example on the T61 the 0 and 1 are for the pata interface used for the optical drive, and the main hard-disk is on host2.
On Ubuntu Hardy Heron with a 2.6.24-16 kernel, a suspend/resume cycle is much quicker if you disable SATA Link Power Management before initiating the suspend. As of Intrepid Ibex and kernel 2.6.27, this should be fixed. (Launchpad bug 234047, Kernel bug 10817)
Laptop Mode Tools
The Laptop Mode Tools utility implements many of the above power-saving measures from disks, and some others.
Optical drive
The optical drive is reported to consume power even when not accessed. See
- Eject the UltraBay optical drive, or just turn off its power supply (i.e., run the appropriate eject script but leave the drive inserted).
- Reduce the spinning speed of the optical drive.
The hald daemon polling tends to maintain the ATA buses out of power saving modes, and to wakeup CDROM drive (except if you have a kernel >= 2.6.24, hal >= 0.5.10, and SATA AN compatible devices). If you have a recent hald version, you can stop this polling when on battery:
hal-disable-polling --device /dev/scd0 # or whatever your CD drive is
start polling again when on ac:
hal-disable-polling --enable-polling --device /dev/scd0 # or whatever your CD drive is
If your hald is not recent enough, consider suspending it when running on battery. Some moderns SATA buses and drivers supports a notification mechanism (SATA AN - Asynchronous Events Notifications) that obsolete the need for polling on modern hardware; support for this feature had been merged in Linux 2.6.24-rc1 and HAL 0.5.10.
LCD Backlight/Brightness
The LCD backlight is one of the very major power drain. Reducing brightness to the lowest readable level will save a lot of battery lifetime. Also, don't forget to configure your screen saver to shutdown the screen backlight (rather than displaying some eye candy), when no activity for a few minutes.
You can also let the system automatically reduce brightness after a period of inactivity.
If you're choosing your Thinkpad laptop model, keep in mind that the screen size affect the battery time greatly: more power needed for larger screens.
The very recent, but xorg standard way to control backlight from CLI is using xbacklight. ie. to set backlight at half the brightness:
xbacklight -set 50
You should configure the DPMS to shutdown the screen when idle (rather than displaying a fancy but power consuming screensaver). ie. to turn off the display after 5 minutes of idling:
xset +dpms xset dpms 0 0 300
Screensaver method
Alternatively, you can add a screensaver that does nothing but blank the screen and turn off the display. In this example, I'm using Linux Mint MATE 17.2, please adjust the keywords below accordingly. Also, you will need to enable DPMS as above, or as in How to make ACPI work#Screen blanking (Standby).
We need to create 2 files, the first one is /usr/share/applications/screensavers/screenoff.desktop
:
[Desktop Entry] Name=Screen off Comment=Turns the screen off Exec=/usr/lib/mate-screensaver/screenoff TryExec=/bin/true StartupNotify=false Terminal=false Type=Application Categories=Screensaver; Keywords=MATE;screensaver;dpms; OnlyShowIn=MATE;
The second one is /usr/lib/mate-screensaver/screenoff
, which needs to be executable:
#!/bin/sh pidof mate-screensaver-preferences | grep -w $PPID && exit 0 xset q | grep -q "Monitor is On" && xset dpms force off
The Keywords
section and the mate-screensaver-preferences
should be customized according to your desktop (like Cinnamon, or GNOME, etc).
After creating those files, open the Screensaver preferences dialog and choose the screensaver with the name "Screen off". Now, when the screensaver is activated, the screen will fade to black and backlight will be turned off by DPMS.
Graphic controllers
All xorg Thinkpad graphics chipsets drivers (ati, radeon, fglrx, i810) have the same bug causing very frequent CPU wakeups when DRI is activated, even when you don't use any 3D application. This problem is partly fixed on xorg git tree but not released as of xorg 7.2. If you value more battery than 3D, you should disable DRI: put this on the /etc/X11/xorg.conf "Device" of you graphic controller:
Option "NoDRI"
Also be sure that DPMS is working: grep DPMS /var/log/Xorg.0.log
should output "DPMS enabled". If not, put Option "DPMS"
in your config.
See the section above about how to enable dpms driven display power saving.
On recent xrandr/xorg versions, you can disable the TV output (or any other detected as connected but not used outputs) when you're not using it: it's known to consume power.
xrandr # see all displays listed here, but that you don't actually use and disable them. xrandr --output TV --off # for instance (if "xrandr" above listed a connected output named "TV" that you don't use)
When you don't have an external monitor plugged, disable CRT and DVI output (for some, this can make a difference in power usage) :
echo crt_disable > /proc/acpi/ibm/video echo dvi_disable > /proc/acpi/ibm/video
Some drivers have specials power saving mode, and/or allows underclocking the GPU. See also:
- How to make use of Graphics Chips Power Management features, or with Rovclock on ATI.
- Problem with high power drain in ACPI sleep
USB Subsystem
The kernel support an efficient USB 2.0 power saving feature if you enabled CONFIG_USB_SUSPEND. This may not trigger in when you have an USB device plugged (and beside, USB devices tends to suck power on their own), so avoid using such devices when on battery. To enable it by default, you must add the line
options usbcore autosuspend=1
to your /etc/modprobe.conf or add it to (and create if necessary) the file /etc/modprobe.d/usbcore depending on how your distribution organises modprobe configuration.
If on the other hand, you have usbcore built into your kernel, you can add this in the kernel boot options (ie. in grub's menu.lst):
usbcore.autosuspend=1
or at runtime, per device, with:
for i in /sys/bus/usb/devices/*/power/autosuspend; do echo 1 > $i; done for i in /sys/bus/usb/devices/*/power/level; do echo auto > $i; done
USB 1.1 is worst. It needs polling the bus frequently, hence can't really go in a low power mode when you enabled it, even if you don't have any device plugged. You'd better remove it when you don't use a 1.1 device:
rmmod uhci_hcd
If you don't intend to use any device needing USB 1.1 (unfortunately, the built-in bluetooth and fingerprint-reader are USB 1.1 devices), the USB 1.1 support can also be totally avoided. On Debian and derivatives, just do:
echo "blacklist uhci_hcd" >> /etc/modprobe.d/blacklist
PCMCIA/CardBus
Same for PCMCIA/CardBus. Some users experiences interrupts clouds (sometime up to several thousands interrupts/second) causing CPU wakeups, thus totally preventing the CPU to reach lower C-states. If you don't use PCMCIA, you may disable it the same way (unloading seems insufficient to restore the system properly, you have to boot without it):
echo "blacklist pcmcia" >> /etc/modprobe.d/blacklist echo "blacklist yenta_socket" >> /etc/modprobe.d/blacklist
Sound
ALSA has a power saving feature that should be enabled on your kernel (CONFIG_SND_AC97_POWER_SAVE). Note that this low power mode won't trigger in unless you muted all sound inputs (micro, line in etc.). This feature has to be activated with:
amixer set Line mute nocap amixer set Mic mute nocap echo Y > /sys/module/snd_ac97_codec/parameters/power_save
Intel HD Audio
If you have Intel HD audio as your onboard sound controller, substitute the following for the last line in the above sequence:
echo Y > /sys/module/snd_hda_intel/parameters/power_save_controller
You also may wish to decrease the sound poweroff timeout to something shorter, like 1 second after last playback:
echo 1 > /sys/module/snd_hda_intel/parameters/power_save
Additional Tweaks
You can unload all sound related modules when you are on battery, or mute the sound system (echo mute > /proc/acpi/ibm/volume).
See also How to enable audio codec power saving.
Wireless Interface
intel wireless
Wireless network consume a lot of power. To save power, you can kill the Wi-Fi radio when it's not in use:
echo 1 > /sys/bus/pci/devices/*/rf_kill
If you need Wi-Fi, you can also reduce power consumption (at the price of performances) by activating the power saving modes:
iwpriv eth1 set_power 5
For drivers using the new Wi-Fi kernel framework (mac80211/cfg80211), the canonical way to do this is now:
for i in /sys/bus/pci/devices/*/power_level ; do echo 5 > $i ; done
Most drivers, like ipw2200, that don't use the new mac80211 framework place the interfaces in aggressive scanning mode when they are not associated with any Access Point, even when the interface is down (more info about this on Intel's LessWatts website). This behavior consumes a lot of power, even more than when the interface is plain active and in use. But this can disabled at module's load time :
rmmod ipw2200 modprobe ipw2200 associate=0
You can fix this setting by placing the following in /etc/modprobe.d/options (Debian/Ubuntu) or in /etc/modprobe.conf (Red Hat/Fedora):
options ipw2200 associate=0
Reducing beacon intervals on your Access Point to 1 per second will also reduce network card interrupts, therefore power savings. This shouldn't have negatives side effects.
In recent kernels, the powersaving on the intel ipw3945 has been disabled, as for some it is unstable. For others it worked just fine.
See this patch. You may wish to try changing '.broken_powersave=true' to false, in /usr/src/linux/drivers/net/wireless/iwlwifi/iwl-3945.c if you wish to enable powersave.
See also, to activate power saving on the wireless network card:
- For Intel PRO/Wireless 2200BG Mini-PCI Adapter and Intel PRO/Wireless 2915ABG Mini-PCI Adapter, see instructions for the ipw2200 driver.
- For Intel PRO/Wireless 3945ABG Mini-PCI Express Adapter, see the ipw3945 driver README
Ethernet Controler
If you don't use Wake-on-LAN, you should disable it for your network card, because it sucks a lot of power:
ethtool -s eth0 wol d
If you can, try to reduce useless network activity on your ethernet segment, coming to your NIC (ie. uneeded broadcasts), those cause interrupts and CPU wakeups.
Forcing 100Mbps full-duplex speed on a gigabit ethernet NIC can also save a lot of power (~1W) on most network workloads. This also reduces components temperature (e.g., thermal sensor 0xC0 on the T43 cools down by 5 degree between 1000Mbps and 100Mbps, and another 1 degree for 10Mbps).
ethtool -s eth0 autoneg off speed 100
Note, however, that if the network device on the other side has auto-negotiation enabled (which is very common) and you turn auto-negotiation off, the other side will assume half-duplex mode and you will experience a significant loss of performance.
Bluetooth
When you don't need bluetooth, disable it. Because of its radio, bluetooth is not power friendly.
hciconfig hci0 down ; rmmod hci_usb echo disable > /proc/acpi/ibm/bluetooth
Modem
When was the last time you used your analog modem? If you can't remember, you probably just don't need it. If it is on a separate module in your laptop, simply remove it. Store it in a ESD safe place (like the bag in which your last addon card or hard drive was packed), in case you should need it again. This won't save you a lot of power and weight, but why carry something around you never use.
System Fans
Fans consumes power when running, so you may look at the ACPI fan control script.
Misbehaving Userland
You should avoid using Beagle, Compiz, Beryl, XMMS, gnome-power-manager and Evolution while on battery. Look at the PowerTOP's known problems list.
Deactivate desktop animations (blinking cursor on the terms, animated wallpapers, ...): they cause regular X (therefore kernel and CPU) wakeups.
In short, while on battery, you should stop all applications that don't really stay idle when you're not using them. This means applications that:
- Wakes up the CPU too often (by polling something, because of too short select() timeouts, ...)
- Access the disks at regular intervals
- Access an hardware bus (USB, ATA, ...) at regular intervals
To find those offenders run:
strace -p $(pidof yourapp)
# for all your running applicationspowertop
dstat -t -c --power --top-cpu --top-io --top-bio --top-latency --top-cputime
sysctl vm.block_dump=1
# and look at dmesgps aux | awk '{print$10,$11}' | sort -n
# will list all running softs sorted by used cpu time
Please, don't forget to fill a bug when you find such a misbehaving software.
See Also
External resources
- Current trends in Linux Kernel Power Management, Dominik Brodowski, 2005
- PowerTOP website
- Power Management Guide from the Gentoo Linux documentation
- When/where/what for low power consumption? (thread on Linux-Thinkpad)
- Intel's LessWatts "Saving power on Linux" website
- 8 hours of battery life on your lap(top) (ODP/PDF), a presentation by Pavel Machek