[TRACKING] Linux battery life tuning

@Aidan: ouch. With Fedora, 11th gen i7, 16 Gb, idle is more in the 3-4W range for me. I imagine more/different memory, different SSD, inserted expansion modules could make this worse. Brightness of screen (if on) is an important factor too.

Otherwise, suspect EndeavourOS might just have too enthusiastic daemon configurations, so that background work ends up keeping the system too awake. But I’d expect that would show up on the system load somewhere. So perhaps it’s some hardware configuration.

You could try and see how a live USB key with Fedora fares: just start it up and see how it idles. Possibly the USB key will add a bit of power usage, but if EndeavourOS were the problem, one would expect even with that to still see improved performance. It could be a useful step in ruling out causes.

1 Like

@Nils I did previously use Zorin (ubuntu) and got exactly the same power usage; maybe I’ll try live environments of a few different distros and see what the power estimations are. I can start with Fedora. Mint has also been recommended to me. Still, it would be too bad if I had to switch over this: I do like Endeavour, and other Endeavour users report normal power usage (though not on Framework), and I know distro-hopping is seen as the cowardly solution to problems like this.

I do need to ask: what do you mean by “daemon configurations?” Isn’t power usage mostly outside the jurisdiction of linux distributions, especially ones like Endeavor, which just provide tlp or powerprofiles daemon and call it a day? And when we talk about alternate RAM / SSDs, we’re talking about tens of milliwatts, right?

A couple other possible clues:

  • I also haven’t been able to get hardware video acceleration to work consistently, despite spending hours and hours troubleshooting.
  • In powertop, the processes I can see all look normal. The busiest use low hundreds of milliwatts; a few use low tens; most use single-digit milliwatts or less. Almost all power usage is lumped together under “Display backlight.” (to be clear: it’s NOT the backlight that’s drawing 10W)

What I did on Fedora is: follow the Linux setup guide from framework (mainly setting the appropriate boot options), deactivate the default power-profiles daemon and installing and activating TLP instead.
→ power-profiles daemon and tlp are known to interfere with each other. Activate only one of these!

Measuring idle power usage (simple approach):

  1. disconnect your charger
  2. close any opened up software (pay attention to any autostart software, possibly running in the background; make sure software is really closed, not just minimized)
  3. lower the display backlight to ~20% (or 1%)
  4. open up powertop
  5. let it idle for one minute (do not touch anything!)
  6. look at the discharge rate

In case of high discharge rate readings:

  1. is the display backlight at 100%? → lower it down
  2. have a look at the tuneables table in powertop - are most of them “good/okay/active”?
  3. is tlp in battery mode (tlp-stat)?
  4. have a look at the overview in powertop and look out for wakeups/s - search for any processes you might recognize, causing > 5; in total, I get down to about 200-500 wakeups/s; system processes may cause higher numbers (e.g. i915, tick_sched_timer, gnome-shell).
  5. start your preferred software, let the laptop idle for one minute and look at the wakeups/s increase - some software simply keeps your device busy for nothing (e.g. MS Teams)
  6. is there any accessory attached to your laptop? Really anything, except for the framework USB-C cards, will draw additional power (even the DP or HDMI cards)
1 Like

@Roy_Meissner Thanks for the detailed reply. Watching powertop for a few minutes after a fresh boot, with minimal screen brightness and no accessories plugged in, I see wakeups per second fluctuate between 300 and 2,000. Power usage is 6-10W. There is no colmun for “wakeups,” but there is one for “Events/s.” Assuming this is the same thing, the major offenders are:

  • “idma64.2”
  • “/usr/bin/plasmashell --no-respawn” (there’s at least two of these)
  • “tick_sched_timer”

–but as I mentioned above, powertop reports the large majority of power usage as “Display backlight,” for some reason. Looking at “Tunables,” they’re all “good” except for “VM writeback timeout” and “Autosuspend for USB device HDMI Expansion Card [Framework].” Changing these to “good” does not make any noticeable change to power usage.

Looking at top, it shows “plasmashell” as using a constant 3% CPU, and no other processes doing anything significant.

+++ TLP Status
State          = enabled
RDW state      = not installed
Last run       = 11:28:01 AM,    122 sec(s) ago
Mode           = battery
Power source   = battery

Regarding what distributions can do to influence power usage: they can choose the flags on their kernel configurations, which may determine power usage. They also choose the version of the kernel, which could be a bigger component. This is something you could work around fairly easily because you can compile and install your own kernel.

Distributions do a lot in tuning all the services around the kernel as well, and those potentially can influence power usage by a lot as well: time-outs on when to set components to lower power states, write-back intervals to disks (causing wake-ups), active-polling for events or checking status (waking up the CPU and possible other components). There must be a lot of compromises and choices in configuring those things and they might add up to significant differences. Since the tuning is so difficult, most distributions will probably use the “factory defaults” from upstream, so this is probably limited too, but for some daemons and services there are different upstreams to choose from, so then the difference can easily be big.

Your desktop manager, for similar reasons, probably makes a BIG difference. For me, Fedora with Gnome on Wayland. I didn’t do much to get to 3-4Watts in idle. So it would be good to rule out that it’s not KDE Plasma that’s the hog …

I have some daemons like Dropbox running, but that doesn’t seem to make much difference. Those would be my first thing to look for, but they’d show up in the system load (although, if they’re mainly wasting energy on I/O perhaps not in CPU usage!)

I do recommend to use a script like [TRACKING] Linux battery life tuning - #214 by Nils to, for instance, once a minute read out the battery charge and compute your power use from that.

Furthermore, with powertop, I get the impression it’s not very good at attributing power usage to different components that are hard to separate by changing parameters: all that powertop has is a table of what’s in use and the power usage over some interval. In its tuning loop it tries to vary what’s in use and then do a regression to split the total power use among the components. That doesn’t work well for components it can’t separate.

In a stock Fedora live USB environment, powertop reports somewhat lower power usage, at around 6W. Only one process has more than 20 events per second: “tick_sched_timer.” Does Fedora use Wayland by default?

This is actually built into KDE, but I don’t quite understand how it helps troubleshoot excessive battery drain…

Fedora 36 does; I think they started that default before I expect they continue defaulting to Wayland for the foreseeable future.

The 2 watts difference compared to my baseline could be due to different/more memory, TLP not running on Fedora Live, 12th gen vs. 11th gen, extra power due to live distribution.

It does suggest that you can gain a few watts on your EndeavourOS by tweaking configurations.

Concerning script: I felt that with the direct numerical data it was easier for me to average power use over some longer time intervals. The graphs felt imprecise to me, also because I was mainly interested in measuring across suspend intervals, where the graphical tools (at least those of gnome) feel very suspect. Powertop does give “instantenous” readings, but would always show activity concerning the reporting as well (CPU time spent on terminal etc.) which made me feel that was not reliable either.

Yeah, I meant events/s - I’m on a german localization.

So just for reference: I got a 12th gen with Bios 3.05, 16G RAM (Hynix) and a 512G Western Digital SN730. Using Fedora 38 with Gnome on Wayland. 2 USB-C and one USB-A cards attached.
To give you something to compare with, here’s what powertop gives me on a freshly booted system after 2mins, with enabled wifi and minimal brightness:

Even though powertop isn’t perfect, it is a good tool to start with as it gives you the current battery discharge rate and CPU wakeups & events. Additionally, it gives you the percentage your CPU is in the different power states (down to level 10). You can use that information to determine if something is keeping your CPU busy, so it can’t reach deep sleep states. As @Nils already pointed out, I wouldn’t count on the power usage per device at all.

As I said, I’m using gnome and gnome-shell takes only 0.3-1% CPU in top. Maybe there’s a misbehaving plasma plugin or something like that on your system?

Also as @Nils said, you’re power usage might be related to your specific system config - NVMe & size, RAM modules & size, Wifi Card, expansion cards, etc… Some simply work better than others in terms of power usage.

I’d try to look for

  1. is the CPU reaching its deep sleep states?
  2. processes causing excessive events/s
  3. any errors or warnings in your system’s journal (maybe there’s a firmware issue, causing some device to constantly loop instead of sleeping)
1 Like

@Aidan three suggestions:

Fiddle with the cpu turbo in BIOS (maybe set to Max Non-Turbo Performance). It’ll throttle, but it gives you a bandaid fix and a diagnosis tool.

Toggle panel self-refresh with a kernel parameter, I know it’s been rumored to cause problems on P/E CPUs.

It’s Arch, someone has built a tickless/dynticks kernel. Try installing that and see if your tick scheduling processes consume less power.

EDIT: #4, see Reddit on idma64

More notes:

Expansion cards (x1 HDMI, x2 USB-A) seem to add about 1W.

When I add tlp to the fedora live environment, power usage gets down close to 5W.

My RAM is 16GB DDR4-3200, and my drive is an Intel 670p Series 1TB (PCIe 3x4)

On both EndeavourOS and Fedora live, when idling, just moving the mouse increases power usage 50%. Is this normal?

My main user-defined background processes are Tidal music, Discord, and ExpressVPN. Together, They add about 1.4W to power consumption when “idling”. I get the impression that this is unusually high for things running in the background.

1 Like

Two electron applications by chance (Discord and Tidal)?

Highly recommend checking out the Reddit thread I linked, idma64 is related to mouse interrupts and a problematic driver spamming said interrupts. Blacklisting it allows for use of a backup driver which doesn’t have the problem.

It appears so. I’m a linux novice; is electron something to avoid?

Not that it’s bad, rather, resource intensive.

Myself, I prefer to run Discord and similar in a browser tab as it means less drain.

1 Like

@Aidan another thing I noticed is you ran powertop --auto-tune try running powertop --calibrate while on battery instead. It will run the backlight through the paces on its own and help determine what the actual powerdraw will be. It takes about 15 minutes to complete, at whihc point you will need to escape out of it on your own. This will make sure your readings are as accurate as they can be.

I average with Firefox, Evolution , and Terminal between 4-5w. So it is possible but you need to track down the individual cultprits.

Fedora currently uses Wayland as the default for the default GNOME and KDE workstation spin. Other spins do not (yet).

Thanks for directing me toward that reddit thread you added to your earlier reply. Checking /proc/interrupts, I do see a lot of interrupts from “43-fasteoi idma64.2, i2c_designware.2”; more than from any other single source.

I experimented with blacklisting i2c-designware-pci and intel_lpss_pci. The former didn’t do anything. The latter did stop the crazy interrupts… but also disabled my mouse entirely. And, oddly, didn’t make a noticeable change to my power consumption.

Following the directions at the top of this thread, I see that PSR is disabled. Changing the prescribed kernel parameter fails to enable it.

That does sound good, but I think it’s beyond my current linux level.

The default Arch kernel is already compiled with CONFIG_NO_HZ_FULL, so it should use dynticks by default.

After reading all of this thread, I’m fairly convinced that mouse interrupts are the main problem. I exactly replicate the dstat -t --top-int output described by a couple other users: putting a finger on the trackpad changes worst-offender interrupts from < 100 to > 2500.

The people in that thread talk about this issue across various systems, so I’d really like to hear who on linux doesn’t experience absurd mouse-related interrupts.

1 Like