[TRACKING] Linux battery life tuning

I have been running into so many issues with battery/performance. I have no idea what is going on as everything runs smoothly on my Dell Latitude 7480. I am running on NixOS with flakes so the entire system is quite literally the exact setup (from reproducibility).

I am using TLP to set up AC/Battery settings. Idle on 50% brightness with powertop open has a discharge rate of ~3.5w. That is all good, my latitude has a discharge rate of about ~3.9w. But that’s where the expected behavior ends.

On battery, this is how everything is running. Omitted some lines for clarity:

/sys/devices/system/cpu/cpu0/cpufreq/scaling_driver    = intel_pstate
/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor  = powersave

/sys/devices/system/cpu/cpu0/cpufreq/energy_performance_preference = power [HWP.EPP]

/sys/devices/system/cpu/intel_pstate/status            = active
/sys/devices/system/cpu/intel_pstate/min_perf_pct      =   9 [%]
/sys/devices/system/cpu/intel_pstate/max_perf_pct      =  50 [%]
/sys/devices/system/cpu/intel_pstate/no_turbo          =   0
/sys/devices/system/cpu/intel_pstate/hwp_dynamic_boost =   0
/sys/devices/system/cpu/intel_pstate/turbo_pct         =  47 [%]
/sys/devices/system/cpu/intel_pstate/num_pstates       =  39

Doing simple activities on Firefox (aka writing this post) I immediately hit 13-15w discharge. Videos are atrocious and send me up to 20-25w discharge with fans running. On my dell latitude it is limited to 10-12w discharge even during videos. This makes no sense as my settings are all firmly in the power saving camp. Its as if the settings aren’t being listened to.

I’d also note that supposedly my cores during heavy video usage are at ~55-60c with ~40% usage all cores and the computer is burning hot (fans are running full blast). When at idle the bottom of the computer/power button is warm to the touch ~40c. And the computer is overall warm at normal web usage at ~45c. The computer is always warm even when not doing anything.

If you read through all of that I am curious your thoughts/experience. I feel I am missing something extremely obvious. Note that these issues also occur outside of firefox with other programs.

tldr: power, temperature, and CPU usage all make no sense.

1 Like

I don’t think you’ve enabled powersave on battery? Check the following lines.

/etc/tlp.conf L0019: PCIE_ASPM_ON_AC="performance"
/etc/tlp.conf L0020: PCIE_ASPM_ON_BAT="powersupersave"

Also, have you enabled hardware acceleration on firefox?

1 Like

I had PCIE_ASPM_ON_** set to default. Tried setting it to powersupersave on battery and no luck. Still same issues.

I spent a bit of time looking into hardware acceleration and also no dice there. I confirmed that VA-API is working and xserver is doing direct rendering. I enabled Guc/Huc and framebuffer compression from the archwiki. Firefox hardware acceleration is broken with intel-media-driver. I get the sandbox violation errors. See this active bug thread: 1619585 - VAAPI video playback leads to sandbox violations (Temporary solution: Uninstall iHD driver (intel-media-driver) and install i965 driver (i965-va-driver == intel-vaapi-driver)). However from my understanding can’t use intel-vaapi-driver with iris xe so out of luck :frowning: . I did get it working with MPV for testing consumption and still was hitting 20+ watt discharge.

Is there anything I might be missing? I am not sure what to do as the laptop is basically unusable. Zoom calls means less than two hours of battery life and fans at full speed. Normal web browsing is three-four hours of battery life. Even pure terminal usage gets me only up to 7-8 hours.

edit: I would also like to add that general performance has been pretty bad. Any GUI program such as Firefox, LibreOffice, and Zoom has noticeable lag and frequently freezes for a few seconds. I am so suprised because everything works great with the same NixOS configuration (with separate drivers of course) on my dell latitude 7480 that has an old dual core i7-7600u with whatever nonexistent integrated graphics.

1 Like

This is super-weird. I’m using Guix and I think the most I’ve seen is 9W while watching videos - with 1W taken by the ethernet adapter, etc.

What kernel version? I’m on:

Linux guixframework 5.13.15-gnu1 #1 SMP 1 x86_64 GNU/Linux

Another thing to do is to wipe and start with ubuntu which has pretty reasonable default battery life of 6-10 hours iirc. If you can’t get it with ubuntu, there’s something weird going on.

You have tested with no adapters, right?

edit: Ubuntu with TLP and powertop --auto-tune had pretty good battery life. Don’t recall if they were installed by default.

What do you mean by no adapters?

It is really weird. I really am lost at what is wrong. Luckily it will be easy to get NixOS setup. Reproducibility really coming in handy (guix + nixos ftw!). Installing ubuntu fresh might be the next step to make sure this isn’t a hardware problem.

Running the latest kernel. And these are the hardware specific things that NixOS auto-generates on setup.

kernelPackage = pkgs.linuxPackages_latest;  # 5.14.5
initrd = [ "xhci_pci" "thunderbolt" "nvme" "usb_storage" "sd_mod" ];
kernelMods = [ "kvm-intel" ];

With none of the expansion cards plugged in. The HDMI and microsd adapters each take 1W when idle right now it looks like.

Ah, I am only running usb-a/usb-c expansion cards. I took them out and it seems to have lowered usage just a little. Still sitting at ~8-9w discharge writing this post with a few tabs open and powertop (and basic system services).

I’m running firefox with 10+ tabs, telegram desktop, various virtual machines, wine, have an ethernet dongle, and powering a 43 inch monitor at 4k resolution.

The last few 20 second intervals have been while I’ve been doing stuff have been:
10.1W
10.3W
9.8W
10.5W
10.7W
9.83W
10.1W

Edit - in addition, playing a youtube video upped it to 12.5W

Interesting, I just spiked up to ~15-20W discharge for around 5 minutes and now am hovering at ~12w. Watching my system monitor I am only averaging 5-15% on all cores. No idea what is taking up all the power. Using a steady 2.3gb of ram and no significant network usage. Nothing has changed since typing the posts.

Omg wow. Ya I have 6 tabs open, all of them various wiki sites and one system monitor TUI. I am running DWM with Picom using startx (no display manager) so it should be extremely minimal on power consumption.

edit: and my cpu frequency clearly has TLP working as powertop has showed it to be consistently at around 1000mhz

Yah, you should also check the idle stats tab on powertop. I’m hitting C6 states 20% of the time while I’m typing and getting 8W usage.

I’m not sure how much frequencies have to do with it. My frequencies are all 1100-1250Mhz.

@IPGentlemann - I’m trying to understand which parts I can put into the wiki/first post. It looks like the power profile daemon is a Fedora-only project?

Is there something specific that the power profile daemon does to reduce the power usage that can be useful in general for non-Fedora?

@TJ1 The power-profiles-daemon is not Fedora-only. I believe it comes Out of the box with Fedora re-spins (will be standard with Fedora 35)

https://fedoraproject.org/wiki/Changes/Power_Profiles_Daemon

and some of the latest Ubuntu Releases.

I know some packages exist for Arch as well.

https://security.archlinux.org/package/power-profiles-daemon

If I recall the daemon originally started as a project targeting Linux systems that were running the standard GNOME desktop,

The power-profiles-daemon project was created to help provide a solution for
two separate use cases, for desktops, laptops, and other devices running a
“traditional Linux desktop”

but KDE/Plasma started support for it fairly recently as well.

I believe I’ve seen some other posts mentioning people running it with other Linux OS’s like NIX, I’ll reply with them linked if I find them again.

1 Like

Created a Max SoC vs Avg Watts vs Battery Life Hours table for the 55 Watt-Hour battery if anyone wants for reference:

@ERLindeman, is the table for all framework configurations in general, or is that with a specific config in mind?

eg: freshly installed fedora instance, or a freshly installed Debian instance with TLP installed… etc. Not just CPU/RAM configs.

@mrwm
It is for a 55 Wh battery, which is the same across all framework laptop configs.
Watts used against Watt-hours of battery to get Hours of life is just division, agnostic of other hardware. All the hardware and configs only change the “Watts Used” variable, which powertop can give you. This table helps you figure out the rest.

So has it been determined whether or note Ubuntu 21.04 needs TLP or Powetop? I have power profiles under the power settings in 21.04. I do use a gnome extension that also me to change the max and min processor states as well as disable turbo boost, and I’m seeing very temps as a result. (My primary focus is keeping temps down, while still doing all of the work I need.)

So I’m just curious if powertop is still necessary?

1 Like

I don’t think you need PT if you run TLP, (there are obvious conflicts to be weary of if running both) but I do, only using PT for monitoring and ‘Tuneables.’

I’m seeing a bad interaction between battery tuning and suspend. I’m running stock Ubuntu MATE 21.04 with the following TLP changes:

CPU_ENERGY_PERF_POLICY_ON_BAT=power
PCIE_ASPM_ON_BAT=powersupersave

With these changes I’m reliably reaching pc10; however, if I suspend (s2idle) the laptop, when it resumes I get only pc1/pc2. After rebooting, it gets down to pc10 again.

Is anyone else seeing this?

1 Like

I’ve been poking at s0ix (“s2idle”) power usage, since the 12-second wakeup delay with S3 (“deep”) annoys me more than the power savings it gives.

I’m using Debian unstable, which has kernel 5.14.9. I’m using TLP with DEVICES_TO_DISABLE_ON_STARTUP=“bluetooth wwan” and PCIE_ASPM_ON_BAT=powersupersave, and everything else at Debian’s defaults. Powertop’s tunables tab says everything is good except the VM writeback, which it seems TLP sets more aggressively than Powertop likes.

I’ve been using /sys/class/power_supply/BAT1/charge_now to check usage with a bit more granularity than looking at percents, which measures in microamp-hours rather than watts or watt-hours. You can convert from amp-hours to watt-hours by multiplying by voltage, but /sys/class/power_supply/BAT1/voltage_now seems to vary which makes the conversion a bit iffy. Based on the battery being stated as 55Wh and charge_full_design saying 3.572Ah, I’m guessing 15.4V is about the right conversion.

I’ve found s2idle reports reaching s0i3.0, which is good.

With 2 USB-C cards and 2 USB-A cards, one on each side, I see about 0.143 amps power usage over extended suspend, which seems to be somewhere around 2.20W or 4%/hour. Not great, but could be worse.

If I take out the USB-A cards, it drops to about 0.096 A (1.48W or 2.74%/h). Putting both A cards on the same side is slightly better than one on each side. The C cards don’t seem to make a difference. I haven’t tried others.

S3 suspend seems to do about 0.03 A better (0.46W or 0.86%/h).

I’ve noticed the same thing, although I get up to pc3. I’ve also found that doing an S3 (“deep”) suspend also seems to fix it.

I also noticed that the ISH line in /sys/kernel/debug/pmc_core/ltr_show shows bogus values after an s2idle suspend if the relevant kernel modules are loaded, and the modules can’t be unloaded in that state. That too is fixed by a reboot or S3 suspend. But I don’t know that that’s directly related, as without the kernel modules loaded ISH doesn’t show bogus values but the CPU still won’t go past pc3.

It doesn’t seem to be anything TLP is doing, as the same happens if I disable TLP.

Yes. Coming out of suspend, I have to re-initiate either or both the powertop --auto-tune or restart tlp. Haven’t figured out why yet, but definitely seen it.

1 Like