Linux battery life tuning

There are many threads on linux battery life. I think we should probably have a wiki page with the relevant information. I’ve dug out some relevant bits from various threads.

Tuning idle power usage

The idle power usage can be tuned down to 2.5W by

$ sudo powertop --auto-tune

This can be enabled as a one-shot on some distributions via systemd service file (via @IPGentlemann)

$ sudo systemctl enable powertop

It is also necessary to configure TLP with the settings:

PCIE_ASPM_ON_BAT=powersupersave

After setting these two items, on the lowest brightness idle you will see the CPU hit C8 states on the second tab of powertop and the overall usage be roughly 2.5W if you have a single DIMM. Without ASPM enabled, the power usage will be between 3-4W.

From @Michael_Wu

Stock, the CPU should be able to reach C8 state, with PSR off. With PSR on the CPU should reach C9/C10. (PSR works when the image on the screen is static, so not when a video is playing on screen, flashing notifications, etc.). Battery Life? - #63 by Brett_Kosinski

Panel self-refresh (WIP)

If PSR is enabled on pre-5.14 kernels, there may be stuttering. To remove PSR see Periodic stuttering on fresh gnome.40 wayland install on Arch Linux - #6 by William_Light

More references:

Tuning disk usage (WIP)

  • Set fstab options for disks to be noatime or relatime [From @Brett_Kosinski ]

Audio usage (WIP)

I’ve unscientifically noticed that pipewire appears to use less power than pulseaudio. The following 3 daemons need to be running for a drop-in replacement for pulseaudio.

pipewire
pipewire-pulse
pipewire-media-session

Expansion Card Power Usage (WIP)

HDMI and SD Card expansions appear to be using 1W whether or not they are in use. There appears to be a fix with autosuspend or perhaps with a newer bios?

DRAM

Note that larger quantities and higher speeds (e.g. 3200 instead of 2666) of memory will result in higher active, idle, and suspend power consumption. There is a detailed study on this here: [Battery Life] Impact of RAM / memory configuration + extra data

Wifi (WIP)

AX210

Note that the vPro version of AX210 (or other Intel WiFi modules) may have power management issues in Linux.

Ath9k

Kernel version

5.13 uses less power than 5.12 (approximately 0.5W)

Video playback tuning (WIP)

Full disk encryption (WIP)

I’ve unscientifically noticed that it is 3W rather than 2.5W idle.

GPU rendering with Firefox and Chrome (WIP)

  • Install igt-gpu-tools

  • Ensure that intel_gpu_top is showing GPU usage when watching video on browser.

  • Firefox 92 → about:config → layers.acceleration.force-enabled

  • Chrome ?

Suspend (TODO)

Battery charge threshold

Bios changes are required to be exposed for this to be available.

30 Likes

Awesome! Thanks for starting this. I just converted it into a wiki post.

3 Likes

FYI, I believe the best practice advice is to use relatime rather than noatime, as the former is safer and the performance benefit is roughly the same.

It’s also worth checking to see if this is the default in your system. I just looked and my /home was mounted with relatime enabled without my doing anything.

Also, worth noting that “powertop --auto-tune” and TLP conflict with one another, so you should use one or the other. Given the success with TLP, my recommendation would be to just stick with that.

Thanks for the compilation @TJ1 !

A few possible corrections (at least from my research):

Stock, the CPU should be able to reach C8 state, with PSR off. With PSR on the CPU should reach C9/C10. (PSR works when the image on the screen is static, so not when a video is playing on screen, flashing notifications, etc.).

I’ve seen reports of it working pre Kernel 5.14.0 on not Fedora. Some fixes for Intel display drivers apparently made it into Kernel 5.14, and I’ve been running 5.14.0 vanilla on Fedora for the past week. Can confirm that PSR works like it should with no stuttering/micro-freezes, with the idle power savings and CPU reaching C9/C10. Had issues on 5.12.x and 5.13.x.

Oh cool, how do you enable it? Is it a compile time option for 5.14 or something that needs to be done with sysctl?

Updating wiki. I can also confirm without PSR it only reaches C8.

Thanks, updated.

Hmmm…do you have more details on where they conflict / overlap? I suppose it should be the autosuspend settings? Is the equivalent of what powertop does the setting

USB_AUTOSUSPEND=1

1 Like

I believe newer kernels have PSR enabled by default. It can be force disabled by adding this kernel boot parameter i915.enable_psr=0 and force enabled with i915.enable_psr=1

PSR status can be checked with:
cat /sys/kernel/debug/dri/0/i915_edp_psr_status

Extra info:

Sidenote, just read this thread on Fedora 35 that confirms PSR works out of the box:

2 Likes

There’s a ton of overlap. Both powertop and TLP touch a lot of different settings, including various power management and auto-suspend settings for a whole host of devices, kernel parameter changes (e.g. VM writeback timeout), and so forth.

1 Like

@TJ1 - regarding PowerTOP / TLP overlap, here’s what the TLP Devs say:

https://linrunner.de/tlp/faq/powertop.html

TL;DR Summary: Using PowerTOP to monitor usage alongside TLP is fine, but running powertop --auto-tune when TLP is running is effectively useless, as any changes that PowerTOP makes will be overwritten by TLP.

2 Likes

Can you paste the /etc/tlp.conf that gets you to 2.5W?

One more point on TLP conflicts: it doesn’t play well with power-profiles-daemon, which is installed & enabled by default in Fedora Linux 35.

1 Like

Not quite what you’re looking for but here’s a dump of tlp-stat on my system which shows the full config:

https://blog.b-ark.ca/assets/files/framework-tlp-stat.txt

Hmmmm…ok. So it appears we need a section for TLP and a section for the power-profiles-daemon. Recommendations?

On my TLP configuration, for some reason I have two USB devices that are not using autosuspend which is why I ran powertop --auto-tune to start. Goodix and an unidentified one. Are they tuned correctly with your configuration? I just don’t see the relevant difference between the two configs:

TLP_ENABLE=1
TLP_DEFAULT_MODE=AC
DISK_IDLE_SECS_ON_AC=0
DISK_IDLE_SECS_ON_BAT=2
MAX_LOST_WORK_SECS_ON_AC=15
MAX_LOST_WORK_SECS_ON_BAT=60
CPU_BOOST_ON_AC=1
SCHED_POWERSAVE_ON_AC=0
SCHED_POWERSAVE_ON_BAT=1
NMI_WATCHDOG=0
ENERGY_PERF_POLICY_ON_AC=performance
ENERGY_PERF_POLICY_ON_BAT=powersave
DISKS_DEVICES="nvme0"
DISK_APM_LEVEL_ON_AC="254 254"
DISK_APM_LEVEL_ON_BAT="128 128"
SATA_LINKPWR_ON_AC=max_performance
SATA_LINKPWR_ON_BAT=min_power
AHCI_RUNTIME_PM_TIMEOUT=15
PCIE_ASPM_ON_AC=performance
PCIE_ASPM_ON_BAT=powersupersave
RADEON_POWER_PROFILE_ON_AC=high
RADEON_POWER_PROFILE_ON_BAT=low
RADEON_DPM_STATE_ON_AC=performance
RADEON_DPM_STATE_ON_BAT=battery
RADEON_DPM_PERF_LEVEL_ON_AC=auto
RADEON_DPM_PERF_LEVEL_ON_BAT=auto
WIFI_PWR_ON_AC=off
WIFI_PWR_ON_BAT=on
WOL_DISABLE=Y
SOUND_POWER_SAVE_ON_AC=0
SOUND_POWER_SAVE_ON_BAT=1
SOUND_POWER_SAVE_CONTROLLER=Y
BAY_POWEROFF_ON_BAT=0
BAY_DEVICE=sr0
RUNTIME_PM_ON_AC=on
RUNTIME_PM_ON_BAT=auto
RUNTIME_PM_ALL=1
RUNTIME_PM_DRIVER_BLACKLIST="radeon nouveau"
USB_AUTOSUSPEND=1
USB_BLACKLIST_WWAN=1
RESTORE_DEVICE_STATE_ON_STARTUP=0


1 Like

So here’s something weird: Initially, autosuspend was enabled:

(this is using TLP to apply power management settings, but powertop for reporting on status of tunables)

However, a short time later, after a USB device reset on the fingerprint reader, autosuspend was no longer enabled.

I then manually re-enabled autosuspend, and have since had two more resets, but this time the autosuspend setting stuck.

I’ll see if I can replicate the circumstances for triggering the issue, but there’s definitely something going on here.

Now, note, aside from TLP, there’s also an intersection with udev. libfprint installs files to /lib/udev/hwdb.d and /lib/udev/rules.d (or, at least, those are the paths on my system) that contain device autosuspend rules and so forth. So I wonder if this behaviour indicates a bug in the libfprint goodixmoc driver or the udev configuration.

2 Likes

Does anybody have any recommendations to enable c-states greater than C1, I am using an arch based distro called Garuda running on kernel 5.14.

Thanks

Heh, that’s exactly what @TJ1 's initial post covers! Using the configuration outlined above, with PSR enabled, my machine regularly idles in C10.

I’ve done the tweaks mentioned above, but I’m still having very bad standby life in Arch. In ~10 hours of standby, the battery dropped by 26%.

I’ve tried using powertop to analyze what happened, but to be honest I don’t understand a lot of the output (mainly pertaining to sleep data).

Anyone have any ideas? I’d appreciate any help, it’s the only thing I don’t like about the laptop atm. My battery life during use is perfectly fine.

Have you tried using s3 sleep instead of s0ix? It’ll take longer to wake but should get you better drain rates.

One other thought/question in general for folks seeing high standby drain on Linux:

  1. Do you have an HDMI or DisplayPort Expansion Card plugged in?
  2. Do you have the vPro version of the AX210?
2 Likes

@nrp Nope for me on both accounts. I’m only using USB-C and USB-A cards (see edit), and I’ve got the non-vPro version of the AX210.

I’m curious if it might be an issue with my kernel version. I ended up having to downgrade to 5.12.15, due to issues with bluetooth on the AX210 with any of the 5.13 kernels I’ve tried.

EDIT: I’m dumb. I swapped in an HDMI card late last night, to demo to a friend. I completely forgot to take it back out. That’s likely a large reason for my bad drain.

1 Like