Difference between revisions of "Power saving"

From ArchWiki
Jump to: navigation, search
m (Grouped two warnings)
m (style)
Line 2: Line 2:
 
This article covers the configuration needed to turn on power saving features. Almost all of the features listed here are worth using whether or not the computer is on AC or battery power. Most have negligible performance impact and are just not enabled by default because of commonly broken hardware/drivers. Reducing power usage means reducing heat, which can even lead to higher performance on a modern Intel or AMD CPU, thanks to [[Wikipedia:Intel Turbo Boost|dynamic overclocking]].
 
This article covers the configuration needed to turn on power saving features. Almost all of the features listed here are worth using whether or not the computer is on AC or battery power. Most have negligible performance impact and are just not enabled by default because of commonly broken hardware/drivers. Reducing power usage means reducing heat, which can even lead to higher performance on a modern Intel or AMD CPU, thanks to [[Wikipedia:Intel Turbo Boost|dynamic overclocking]].
  
==Ready to run scripts==
+
== Ready to run scripts ==
 +
 
 
There are already a couple of scripts and tools which make use of the various settings described in the next section. These are notably:
 
There are already a couple of scripts and tools which make use of the various settings described in the next section. These are notably:
  
Line 14: Line 15:
 
If you do not want to take care of the settings by yourself it is recommended to use these tools. But be aware of running only '''one''' of these tools to avoid possible conflicts as they all work more or less similar.
 
If you do not want to take care of the settings by yourself it is recommended to use these tools. But be aware of running only '''one''' of these tools to avoid possible conflicts as they all work more or less similar.
  
=Custom settings=
+
== Custom settings ==
 +
 
 
If you would like to create your own scripts and power saving settings such as by udev rules you can take the following settings as a reference.
 
If you would like to create your own scripts and power saving settings such as by udev rules you can take the following settings as a reference.
  
==Audio==
+
=== Audio ===
  
 
By default, audio power saving is turned off by most drivers. It can be enabled by setting the power_save parameter to a time (in seconds) to go in idle.
 
By default, audio power saving is turned off by most drivers. It can be enabled by setting the power_save parameter to a time (in seconds) to go in idle.
Line 31: Line 33:
 
{{hc|/etc/modprobe.d/audio_power_save.conf|2=options snd_ac97_codec power_save=1}}
 
{{hc|/etc/modprobe.d/audio_power_save.conf|2=options snd_ac97_codec power_save=1}}
  
== Active state power management==
+
=== Active state power management ===
  
 
To verify that [[Wikipedia:Active State Power Management|ASPM]] is enabled:
 
To verify that [[Wikipedia:Active State Power Management|ASPM]] is enabled:
Line 45: Line 47:
 
* On systems that don't support it forcing on ASPM can even increase power consumption.}}
 
* On systems that don't support it forcing on ASPM can even increase power consumption.}}
  
== Backlight ==
+
=== Backlight ===
  
 
When system starts, screen backlight is set to maximum by default. This can be fixed by specifying backlight level in the following udev rule:
 
When system starts, screen backlight is set to maximum by default. This can be fixed by specifying backlight level in the following udev rule:
Line 54: Line 56:
 
</nowiki>}}
 
</nowiki>}}
  
== Bluetooth ==
+
=== Bluetooth ===
 +
 
 
{{expansion|reason=The device should likely be disabled with hciconfig first.}}
 
{{expansion|reason=The device should likely be disabled with hciconfig first.}}
 
[[Kernel_modules#Blacklisting|Blacklist]] the {{ic|hci_usb}} module if the driver is loaded automatically.
 
[[Kernel_modules#Blacklisting|Blacklist]] the {{ic|hci_usb}} module if the driver is loaded automatically.
Line 69: Line 72:
 
</nowiki>}}
 
</nowiki>}}
  
== Web-Camera ==
+
=== Web-Camera ===
 +
 
 
If you won't use integrated web camera then [[Kernel_modules#Blacklisting|blacklist]] the {{ic|uvcvideo}} module.
 
If you won't use integrated web camera then [[Kernel_modules#Blacklisting|blacklist]] the {{ic|uvcvideo}} module.
  
==Disabling NMI watchdog==
+
=== Disabling NMI watchdog ===
 +
 
 
The [[Wikipedia:Non-maskable interrupt|NMI]] watchdog is a debugging feature to catch hardware hangs and cause a kernel panic. On some systems it can generate a lot of interrupts, causing a noticeable increase in power usage.
 
The [[Wikipedia:Non-maskable interrupt|NMI]] watchdog is a debugging feature to catch hardware hangs and cause a kernel panic. On some systems it can generate a lot of interrupts, causing a noticeable increase in power usage.
  
Line 79: Line 84:
 
or add {{ic|1=nmi_watchdog=0}} as a [[kernel parameter]] to disable it completely from early boot.
 
or add {{ic|1=nmi_watchdog=0}} as a [[kernel parameter]] to disable it completely from early boot.
  
==Disabling Wake-on-LAN==
+
=== Disabling Wake-on-LAN ===
  
 
[[Wikipedia:Wake-on-LAN|Wake-on-LAN]] can be a useful feature, but if you're not making use of it then it's simply draining extra power waiting for a magic packet while in suspend.
 
[[Wikipedia:Wake-on-LAN|Wake-on-LAN]] can be a useful feature, but if you're not making use of it then it's simply draining extra power waiting for a magic packet while in suspend.
Line 91: Line 96:
 
{{Note|This should be combined with [[udev#Network device|static naming]] of devices, the {{ic|eth*}} names are not static.}}
 
{{Note|This should be combined with [[udev#Network device|static naming]] of devices, the {{ic|eth*}} names are not static.}}
  
== PCI Runtime Power Management ==
+
=== PCI Runtime Power Management ===
  
 
{{hc|/etc/udev/rules.d/pci_pm.rules|2=ACTION=="add", SUBSYSTEM=="pci", ATTR{power/control}="auto"}}
 
{{hc|/etc/udev/rules.d/pci_pm.rules|2=ACTION=="add", SUBSYSTEM=="pci", ATTR{power/control}="auto"}}
  
==Wireless power saving==
+
=== Wireless power saving ===
 +
 
 
{{Accuracy|This method does not seem to work at the moment.}}
 
{{Accuracy|This method does not seem to work at the moment.}}
  
Line 108: Line 114:
 
{{hc|/etc/udev/rules.d/wifi_power_save.rules|2=ACTION=="add", SUBSYSTEM=="net", KERNEL=="wlan*" RUN+="/usr/sbin/iw dev %k set power_save on"}}
 
{{hc|/etc/udev/rules.d/wifi_power_save.rules|2=ACTION=="add", SUBSYSTEM=="net", KERNEL=="wlan*" RUN+="/usr/sbin/iw dev %k set power_save on"}}
  
== Writeback Time ==
+
=== Writeback Time ===
 
Increasing the VM dirty writeback time can help to aggregate I/O together - reducing disk writes, and decreasing power usage:
 
Increasing the VM dirty writeback time can help to aggregate I/O together - reducing disk writes, and decreasing power usage:
  
Line 115: Line 121:
 
To do the same for journal commits with ext4 and some other filesystems, use {{ic|1=commit=15}} as a parameter in [[fstab]] or with the {{ic|rootflags}} [[kernel parameter]].
 
To do the same for journal commits with ext4 and some other filesystems, use {{ic|1=commit=15}} as a parameter in [[fstab]] or with the {{ic|rootflags}} [[kernel parameter]].
  
== Laptop Mode ==
+
=== Laptop Mode ===
 
    
 
    
 
{{hc|/etc/sysctl.d/laptop_mode.conf|2=vm.laptop_mode = 5}}
 
{{hc|/etc/sysctl.d/laptop_mode.conf|2=vm.laptop_mode = 5}}
  
== SATA Active Link Power Management ==
+
=== SATA Active Link Power Management ===
 +
 
 
{{Note|This adds latency when accessing a drive that has been idle, so it's one of the few settings that may be worth toggling based on whether you're on AC power.}}
 
{{Note|This adds latency when accessing a drive that has been idle, so it's one of the few settings that may be worth toggling based on whether you're on AC power.}}
 
  {{hc|/etc/udev/rules.d/hd_power_save.rules|2=SUBSYSTEM=="scsi_host", KERNEL=="host*", ATTR{link_power_management_policy}="min_power"}}
 
  {{hc|/etc/udev/rules.d/hd_power_save.rules|2=SUBSYSTEM=="scsi_host", KERNEL=="host*", ATTR{link_power_management_policy}="min_power"}}
  
== USB Autosuspend ==
+
=== USB Autosuspend ===
 +
 
 
To enable USB autosuspend after 2 seconds of inactivity:
 
To enable USB autosuspend after 2 seconds of inactivity:
 
  {{hc|/etc/udev/rules.d/usb_power_save.rules|2=ACTION=="add", SUBSYSTEM=="usb", TEST=="power/control" ATTR{power/control}="auto"
 
  {{hc|/etc/udev/rules.d/usb_power_save.rules|2=ACTION=="add", SUBSYSTEM=="usb", TEST=="power/control" ATTR{power/control}="auto"
 
ACTION=="add", SUBSYSTEM=="usb", TEST=="power/autosuspend" ATTR{power/autosuspend}="2"}}
 
ACTION=="add", SUBSYSTEM=="usb", TEST=="power/autosuspend" ATTR{power/autosuspend}="2"}}
  
== Device Power Management ==
+
=== Device Power Management ===
 +
 
 
{{accuracy|reason=Should be done with a udev rule.}}
 
{{accuracy|reason=Should be done with a udev rule.}}
  
Line 135: Line 144:
  
 
== View Power Setings ==
 
== View Power Setings ==
 +
 
This function shows various power settings.  Note you either must be root or you must have sudo.
 
This function shows various power settings.  Note you either must be root or you must have sudo.
  

Revision as of 17:13, 6 June 2013

This article covers the configuration needed to turn on power saving features. Almost all of the features listed here are worth using whether or not the computer is on AC or battery power. Most have negligible performance impact and are just not enabled by default because of commonly broken hardware/drivers. Reducing power usage means reducing heat, which can even lead to higher performance on a modern Intel or AMD CPU, thanks to dynamic overclocking.

Ready to run scripts

There are already a couple of scripts and tools which make use of the various settings described in the next section. These are notably:

If you do not want to take care of the settings by yourself it is recommended to use these tools. But be aware of running only one of these tools to avoid possible conflicts as they all work more or less similar.

Custom settings

If you would like to create your own scripts and power saving settings such as by udev rules you can take the following settings as a reference.

Audio

By default, audio power saving is turned off by most drivers. It can be enabled by setting the power_save parameter to a time (in seconds) to go in idle.

Note: Toggling the audio card's power state can cause a popping sound or noticeable latency on some broken hardware.
Intel
/etc/modprobe.d/audio_power_save.conf
options snd_hda_intel power_save=1
ac97
/etc/modprobe.d/audio_power_save.conf
options snd_ac97_codec power_save=1

Active state power management

To verify that ASPM is enabled:

$ cat /sys/module/pcie_aspm/parameters/policy
[default] performance powersave

Either [default] or [powersave] means you do not need to force it on.

Otherwise, it's either unsupported/broken on your hardware, or has to be forced on with pcie_aspm=force on the kernel line.

Warning:
  • Forcing on ASPM can cause a freeze/panic, so make sure you have a way to undo the option if it doesn't work.
  • On systems that don't support it forcing on ASPM can even increase power consumption.

Backlight

When system starts, screen backlight is set to maximum by default. This can be fixed by specifying backlight level in the following udev rule:

/etc/udev/rules.d/backlight.rules
## SET BACKLIGHT
SUBSYSTEM=="backlight", ACTION=="add", KERNEL=="acpi_video0", ATTR{brightness}="1"

Bluetooth

Tango-view-fullscreen.pngThis article or section needs expansion.Tango-view-fullscreen.png

Reason: The device should likely be disabled with hciconfig first. (Discuss in Talk:Power saving#)
Blacklist the hci_usb module if the driver is loaded automatically.

Alternatively, blacklist the btusb and bluetooth modules.

Another variant is to rfkill it:

# rfkill block bluetooth

Or with udev rule:

/etc/udev/rules.d/bt.rules
## DISABLE BLUETOOTH
SUBSYSTEM=="rfkill", ATTR{type}=="bluetooth", ATTR{state}="0"

Web-Camera

If you won't use integrated web camera then blacklist the uvcvideo module.

Disabling NMI watchdog

The NMI watchdog is a debugging feature to catch hardware hangs and cause a kernel panic. On some systems it can generate a lot of interrupts, causing a noticeable increase in power usage.

/etc/sysctl.d/disable_watchdog.conf
kernel.nmi_watchdog = 0

or add nmi_watchdog=0 as a kernel parameter to disable it completely from early boot.

Disabling Wake-on-LAN

Wake-on-LAN can be a useful feature, but if you're not making use of it then it's simply draining extra power waiting for a magic packet while in suspend.

Disabling for all Ethernet interfaces:

/etc/udev/rules.d/disable_wol.rules
ACTION=="add", SUBSYSTEM=="net", KERNEL=="eth*" RUN+="/usr/bin/ethtool -s %k wol d"

You can use multiple names in the matches; for example, KERNEL=="lan0|eth*"

Note: This should be combined with static naming of devices, the eth* names are not static.

PCI Runtime Power Management

/etc/udev/rules.d/pci_pm.rules
ACTION=="add", SUBSYSTEM=="pci", ATTR{power/control}="auto"

Wireless power saving

Tango-inaccurate.pngThe factual accuracy of this article or section is disputed.Tango-inaccurate.png

Reason: This method does not seem to work at the moment. (Discuss in Talk:Power saving#)

Enabling for a specific interface:

Note: This should be combined with static naming of devices, the eth* names are not static. In the below examples there are some assumptions about how your devices are named. The first assumes that your wireless has the kernel name of "wifi0" and the second that any wireless interface will begin with "wlan". Of course, with persistent naming included now in systemd, this is probably no longer the case. "%k" in the second example is a variable for the kernel name for the matched device. For example if it finds that the rule is applicable to wlan1, the "%k" variable will be replaced ith "wlan1".
/etc/udev/rules.d/wlan0_power_save.rules
ACTION=="add", SUBSYSTEM=="net", KERNEL=="wifi0" RUN+="/usr/sbin/iw dev wifi0 set power_save on"

Enabling for all interfaces:

/etc/udev/rules.d/wifi_power_save.rules
ACTION=="add", SUBSYSTEM=="net", KERNEL=="wlan*" RUN+="/usr/sbin/iw dev %k set power_save on"

Writeback Time

Increasing the VM dirty writeback time can help to aggregate I/O together - reducing disk writes, and decreasing power usage:

/etc/sysctl.d/dirty_writeback.conf
vm.dirty_writeback_centisecs = 1500

To do the same for journal commits with ext4 and some other filesystems, use commit=15 as a parameter in fstab or with the rootflags kernel parameter.

Laptop Mode

/etc/sysctl.d/laptop_mode.conf
vm.laptop_mode = 5

SATA Active Link Power Management

Note: This adds latency when accessing a drive that has been idle, so it's one of the few settings that may be worth toggling based on whether you're on AC power.
/etc/udev/rules.d/hd_power_save.rules
SUBSYSTEM=="scsi_host", KERNEL=="host*", ATTR{link_power_management_policy}="min_power"

USB Autosuspend

To enable USB autosuspend after 2 seconds of inactivity:

/etc/udev/rules.d/usb_power_save.rules
ACTION=="add", SUBSYSTEM=="usb", TEST=="power/control" ATTR{power/control}="auto"
ACTION=="add", SUBSYSTEM=="usb", TEST=="power/autosuspend" ATTR{power/autosuspend}="2"

Device Power Management

Tango-inaccurate.pngThe factual accuracy of this article or section is disputed.Tango-inaccurate.png

Reason: Should be done with a udev rule. (Discuss in Talk:Power saving#)
echo auto | tee /sys/bus/i2c/devices/*/power/control > /dev/null
echo auto | tee /sys/bus/spi/devices/*/power/control > /dev/null

View Power Setings

This function shows various power settings. Note you either must be root or you must have sudo.

function aa_power_settings ()
{ 
  sudo bash -c '
    for i in `find /sys/devices -name "bMaxPower"`;
    do
        for ii in `find $i -type f`;
        do
            bd=`dirname $ii`;
            busnum=`cat $bd/busnum`;
            devnum=`cat $bd/devnum`;
            title=`lsusb -s $busnum:$devnum`;
            echo -e "\n\n+++ $title\n  -$bd\n  -$ii";
            for ff in `find $bd/power -type f ! -empty 2>/dev/null`;
            do
                v=`cat $ff 2>/dev/null|tr -d "\n"`;
                [[ ${#v} -gt 0 ]] && echo -e " `basename $ff`=$v";
                v=;
            done | sort -g;
        done;
    done;
    echo -e "\n\n\n+++ Kernel Modules\n";
    for m in `command lspci -k|sed -n "/in use:/s,^.*: ,,p"|sort -u`;
    do
        echo "+ $m";
        systool -v -m $m 2> /dev/null | sed -n "/Parameters:/,/^$/p";
    done
  ';
}

See also