Linux battery life tuning

LOL, aren’t we all! :smiley: Here’s hoping you get better performance overnight tonight!

Something we’re still working on resolving…

6 Likes

I believe I have psr enabled, here is the output of “sudo cat /sys/kernel/debug/dri/0/i915_edp_psr_status”:
Sink support: yes [0x03]
PSR mode: PSR2 enabled
Source PSR ctl: enabled [0xc2044a16]
Source PSR status: SLEEP [0x30010136]
Busy frontbuffer bits: 0x00000000
Frame: PSR2 SU blocks:
0 1
1 173
2 173
3 173
4 173
5 0
6 173
7 173
PSR2 selective fetch: disabled

I still only see C0 and C1 having usage in powertop.

What’s your kernel version? I’m using 5.13 and am only seeing C8 states also, never reached C10. Apparently, we need 5.14 from @Michael_Wu testing. Seems a bit weird you’re seeing only C1 / C2 though. Something else must be missing?

In my testing, the microsd card also seems to have the same issue of power drain of 1W while not in use. Have not been able to get it to have lower-power draw yet, but I was playing around with so much stuff, maybe I missed something.

Anyone else noticing high battery usage from the device btusb? Mine shows that as the top power user during idle. One example point in time:

Power est. 3.21W 100% Device Radio device: btusb

And that’s with Bluetooth turned off in the GUI settings.

Any ideas?

Is that a powertop estimate? Powertop seems to guess randomly what’s using power. The only number actually reported by hardware is total power consumption. On multiple laptops I’ve had it report the wifi or bluetooth using dozens of watts.

1 Like

Yes, that’s from Powertop, and it did look like at least 90% of the total at the time, so it must just be an artifact. Thanks!

For y’all that aren’t reaching C9/C10 and have PSR enabled:

  • Check that CPU usage is around ~0% and no process is consuming excess in something like top
  • important: ensure the screen can be static, meaning nothing is moving, changing, flashing, etc. on the display. How PSR works is if nothing needs to be updated on the display, no new info needs to be sent to the display. So, the display engine in the CPU can be turned off, allowing C9/C10.

As an example: I had a low battery alert styling in Waybar. At 15%, the color of a small rectangle in my tray would constantly transition linearly between red and white. That simple action constantly updated the display, preventing the CPU from reaching C9/C10 and causing increased idle power consumption.

Here’s some interesting info from Intel, for 11th Gen. Under 11th Generation Intel® Core™ Processor Family (for U-series, not Desktop) > Documents > Datasheet, Volume 1

image

Table 3-5: Some criteria to reach C9/C10:
ksnip_20210914-115958

Table 3-6: With up to a resolution of 5210x3200@60Hz, and PSR enabled, the CPU can reach C10.
Table 3-7: Seems like the USB4 controller plays a part in reaching C10 as well, so maybe check your USB devices. I can confirm my laptop reaches C10 with the HDMI Expansion Card plugged in, as well as in performance governor.
ksnip_20210914-120232


This has happened to me a few times :joy:

Er, 5.14 is needed on Fedora to fix the PSR micro-stutter issue. PSR can still be enabled in the recent earlier kernels which allow reaching C9/C10 (can personally confirm).

Echoing this as well – ~2.6%/hr seems to be about what I’m getting on Fedora 34 which is much higher than it could be. I plan on using suspend-then-hibernate (similar to Windows) for better standby life. Some Linux hibernation info here, and the ongoing Windows discussion here, for comparison. Will report back once I dive into this!

From what I’ve gathered:

If this is S0 suspend (s2idle in /sys/power/mem_sleep), which should be S0ix on 11th Gen, being able to reach C10 plays a role in better standby battery life, so ensure that’s happening.

If this is S3 suspend (deep in /sys/power/mem_sleep), well, according to this System76 engineer:

It was discovered, deep in one of the Intel documents, that TigerLake-U no longer officially supported S3 suspend.

so maybe that’s why S3 suspend seems subpar, FWIW.

7 Likes

@TJ1 I’m also seeing the same draw with the microsd card :frowning:

It prevents the system from reaching PC 9 or 10 and costs over a full watt

1 Like

I’m getting pretty subpar 8w performance on Manjaro +KDE

I can get it down to 5 watts if I unplug the microsd card, disable WiFi and Bluetooth, and log in to the virtual console (not plasma)

I’ve tried setting everything mentioned here and I’m not sure where the extra power draw is going. The CPU is spending most of its time in C9-10 and the GPU is idling.

Plasma has …something wrong with it as the CPU usage is always 1-2%. But even in the console mode it looks like I’m several watts higher than the expected base draw

Silly question - brightness set to minimum and keyboard backlight off? When I was first testing, the keyboard backlight got me. The fact it’s C9-C10 means all the power settings should be there, but maybe do powertop --auto-tune one more time with 2.14? Did you use rfkill to disable the wifi? And what’s your kernel version?

I’m hitting pc10 on Manjaro Gnome 21.1.2 but if I disable PSR (to fix the stuttering issue Periodic stuttering on fresh gnome.40 wayland install on Arch Linux - #6 by William_Light) the lowest I can get is pc8.

I can confirm default Manjaro Gnome installation gets pc10 for me as well (and better battery life than Windows with all its background processes). I thought I was going crazy due to the random stuttering, but I think I can live with it for a while until a battery-friendly fix is available.

Another item I have noticed… pcie aspm is supported:
[ 1.010937] acpi PNP0A08:00: _OSC: OS supports [ExtendedConfig ASPM ClockPM Segments MSI EDR HPX-Type3]

But never changes from default normally:

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

I’m not sure if thats because it’s adjusting, but not updating that or what… but if I set that to powersupersave it seems to allow cpu to get to lower states (C10, etc) here.
Unclear if it helps battery life yet.

Been messing with the power settings on my Framework for the past week and I figured I should post my own findings for others here. I’m running Fedora 34’s KDE/Plasma spin on it’s latest 5.13.15 kernel. I have messed with tuned, tlp, powertop and the power-profiles-daemon and ran with many of the configurations suggested on the various threads where it has been discussed.

Running with tuned or tlp alongside powertop I was definitely seeing an increase in battery-life, the cpu was routinely getting put into C7 states, but it wasn’t really enough. Usage typically wouldn’t fall below 6 watts. I was looking at anywhere from 5-7 hours of battery on a light workload (A few tabs of Firefox, Discord in the background, LibreOffice Writer.)

By far the best setup I have found is the power-profiles-daemon running alongside powertop. The power-saver profile gets the cpu into C10 states better than the other tools and I’m now looking at 4-6 hours for a heavy workload and anywhere from 8-12 on a lighter workload. At full idle, I have seen the laptop dip down to 3.2 watts of usage thanks to PSR.

Additional tips & tricks:

  • Automation: I like to switch between power profiles when I am plugged in to AC so I can do heavier workloads and some light gaming on the laptop when the situation calls for it. With powertop installed, I have set up some udev triggers to change the power-profiles-daemon’s active profile depending on whether or not I am running on battery or AC. I made the /etc/udev/rules.d/10-power.rules file below.
SUBSYSTEM=="power_supply", ATTR{online}=="0", RUN+="/usr/bin/at -M -f /lib/udev/power-profiles/power-saver now"
SUBSYSTEM=="power_supply", ATTR{online}=="1", RUN+="/usr/bin/at -M -f /lib/udev/power-profiles/performance now"

The triggers run the shell scripts I made at /lib/udev/power-profiles. These shell scripts just run the “powerprofilesctl set” command for the profiles I want running in each power state. Running these comands through /usr/bin/at isn’t 100% necessary, but udev runs it’s triggers before a lot of modules are loaded at boot. Running your commands through at is a quick way to make sure your triggers are processed after more kernel modules are loaded.
TL:DR of this is that running these udev triggers through at allows this to work on system boot in addition to changing profiles whenever the system is plugged in or put on battery. I have the system set to performance on AC and power-saver on battery.

  • Be mindful of peripherals
    Simple one, but some applications like Discord will try to connect to the camera if it sees it. the camera draws quite a bit of power on it’s own (a couple watts, even at idle form my observations,) so just be mindful about turning it off when not in use on battery power. Same goes with the microhpone and any expansion cards you may have installed. From reading other threads, it seems the HDMI and MicroSD modules have some idle power draw as well.
7 Likes

Thanks for the detail and udev triggers @IPGentlemann! To add on, initially I ran and saw good results with power-profiles-daemon. I then experimented with TLP and simply haven’t bothered to revert (though I wanted to because power-profiles-daemon is much simpler + Fedora 35 includes it by default, etc.). With your findings, I’m going to switch back. But since power-profiles-daemon doesn’t apply many of the tweaks that TLP does, I’m curious @IPGentlemann:

  1. Are you setting some/all of the recommended tweaks/tunables from powertop? If so,
  2. Which have you set/are using?
  3. How are you applying them? e.g. powertop --auto-tune at boot, via udev rules, etc.

For those using Waybar + power-profiles-daemon, here’s the custom module I run. It displays the current power profile (refreshes every 60 seconds), and a left/middle/right click on the area sets the respective power profile. This functionality already exists in Gnome control center Settings → Power (and from a quick search, I believe KDE/Plasma now has support as well).

Click Action
Left (one finger tap or physical left click) set power-saver profile
Middle (three finger tap) set balanced profile
Right (two finger tap or physical right click) set performance profile
"custom/power_profile": {
    "exec": "powerprofilesctl get",
    "interval": 60,
    "on-click": "powerprofilesctl set power-saver",
    "on-click-right": "powerprofilesctl set balanced",
    "on-click-middle": "powerprofilesctl set performance"
}
1 Like

@Michael_Wu I am using Powertop’s tweaks. Powertop comes with a .service file that you can enable with systemctl.

sudo systemctl enable powertop

This service will run at boot, apply Powertop’s tweaks and then shut itself off once it is finished. No custom bootup scripts or udev triggers required.

3 Likes

While I added the grub line for it, I haven’t actually suspended since I received my framework. It cold boots quick enough I always do a complete shutdown.

1 Like

Just tested with my i7-1165G7 model this afternoon on Gnome Manjaro (kernel 5.13.15-1-MANJARO) and I saw 24% battery drain in 6 hours and 44 minutes. So about 3.56%/hr suspended with lid closed the whole time starting at 97%.

I haven’t done any tweaking of power settings yet, but like @malachid, I’ve just been shutting down completely when I’m not using my laptop. The 19s cold boot time blows any other computer I’ve used regularly out of the water.

2 Likes