[TRACKING] Linux battery life tuning

It’s a Gnome extension called Vitals

5 Likes

Some more testing and it looks like my 2x USBA adapters may be the culprit. Removing them doesn’t affect s2idle much (still about 25mA) but deep is now 19mA. Less than s2idle and nowhere near the 75mA I was seeing. A very strange result but the only correlation I can find. I tried an NVMe firmware update, loading additional i915 firmware, etc. nothing affected deep until I removed the USBA adapters.

1 Like

Actually… back in April, you seemed to be saying that nvme.noacpi=1 had an effect only in s2idle (as opposed to deep) sleep mode, any update on that?

1 Like

I did that here:

It looks like s2idle vs deep doesn’t have as big of an effect as I thought it would, about 50mW difference. nvme.noacpi=1 shaves off only 10mW, possibly within the margin of errors of my measurements.

Still, 50mW, over the whole battery life, means two less days battery, so deep is definitely worth it for me.

1 Like

There are some news about upcoming enhancements in kernel too.

12 Likes

I’ve edited the wiki to reflect that disabling rdd is not only not required to get hardware decoding working, it actively reduces the security of the browser by disabling the sandbox.

5 Likes

Did someone notices worse battery performance with kernel 6.0.6 ?
The camera is sucking power even if not used according to powertop.
I checked if autosuspend was set, and it is.
Manually flipping the hardware switch to off fixes the issue.
But I didn’t have to do that in 6.0.5.

Edit: I rollbacked an old kernel and still have the issue, so it’s something else.
Edit2: https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/2669

2 Likes

@IPGentlemann

I enabled the powertop service. It always shows the following:

$ sudo systemctl status powertop -l
○ powertop.service - Extend the battery life of laptop
     Loaded: loaded (/lib/systemd/system/powertop.service; enabled; vendor preset: enabled)
     Active: inactive (dead) since Wed 2022-11-02 17:39:20 CET; 2min 4s ago
    Process: 192272 ExecStart=/usr/sbin/powertop --auto-tune (code=exited, status=0/SUCCESS)
   Main PID: 192272 (code=exited, status=0/SUCCESS)
        CPU: 3.266s

Nov 02 17:39:15 lamy powertop[192272]: glob returned GLOB_ABORTED
Nov 02 17:39:18 lamy powertop[192272]: Leaving PowerTOP
Nov 02 17:39:20 lamy powertop[192272]: Cannot load from file /var/cache/powertop/saved_parameters.powertop
Nov 02 17:39:20 lamy powertop[192272]: File will be loaded after taking minimum number of measurement(s) with battery only
Nov 02 17:39:20 lamy powertop[192272]: Cannot load from file /var/cache/powertop/saved_parameters.powertop
Nov 02 17:39:20 lamy powertop[192272]: File will be loaded after taking minimum number of measurement(s) with battery only
Nov 02 17:39:20 lamy powertop[192272]: To show power estimates do 113 measurement(s) connected to battery only
Nov 02 17:39:20 lamy systemd[1]: powertop.service: Deactivated successfully.
Nov 02 17:39:20 lamy systemd[1]: Finished Extend the battery life of laptop.
Nov 02 17:39:20 lamy systemd[1]: powertop.service: Consumed 3.266s CPU time.

How can I find out if its working fine?

1 Like

Looks like you haven’t run powertop while on battery, it hasn’t written any metrics to those files yet. Once you do run powertop while on battery, those files will be created and they’ll store the parameters they are talking about.

The service just essentially runs powertop --autotune for you. You’ll know it worked if all the services under the tunables tab in powertop are reporting good.

1 Like

A bit late to the party but I noticed my 11th gen has considerably better battery once my VPN kill switch was enabled, I believe this is due to it disabling wifi on standby

1 Like

So, just for reference for folks. I installed the Linux-Clear kernel today. I also removed the redshift package, and with these changes, I dropped my average poweruse down to about 5.47 wh, with Bluetooth and wifi active. I don’t know what that Intel kernel has going for it, but this has been a reduction of power use by about 30% for me.

4 Likes

I am not running any sort of power config and my i5-1240p is running amazingly.

While comparing and swapping between Fedora’s power-profiles-daemon and TLP I found that running the machine without either of them gets me exactly what I want. I get 3-4W idles and reach C10 easily. I average 5-7W when browsing. I get a .50-.60 percent battery drain per hour with the lid shut. 2D games run at about 10W average, and Portal 2 averages 16W at native res (AA disabled). If I want to run something demanding like modded minecraft, I can still get the processor cooking at about 45+ W with feral gamemode.

Is there something I’m missing here? I checked systemctl and confirmed TDP is uninstalled and PPD is disabled. It feels like I’m running a very good power manager but I definitely am not.

2 Likes

My Setup:

  • 12th gen 1240P, 32GB Ram (2x16GB), Intel Corporation Wi-Fi 6 AX210/AX211/AX411 160MHz (rev 1a)
  • WD_BLACK SN770 1TB (731100WD)
  • BIOS 03.06
  • Linux 6.1.3
  • 2 USB C, 1 HDMI, 1 USB 2, all disconnected
  • Grub: GRUB_CMDLINE_LINUX_DEFAULT="loglevel=4 pcie_aspm=off nvme_core.default_ps_max_latency_us=0 nvme.noacpi=1 mem_sleep_default=deep"

My Results:

17% usage in 10 hours. I think 1,7% drain within 10 hours is within the expected range?

2 Likes

@Miguel_Parra I don’t think you are missing anything. Newer processors are very good at managing their power. The primary reason to use TLP is to disable turbo boost on battery and to model behavior for Bluetooth, docks, drives, etc. Power profiles does not offer this which is why it does not even enter the picture for me.

1 Like

@Jason_Hottelet This is a very late reply to your question about unbinding USB drivers, but in case you are still interested, these steps may allow you to bind/unbind USB drivers. I have found that my computer will lock up when TLP is running if I run these commands, but I have found that the improvement in battery life that comes when the USB cards are unbound results in longer battery life than I can get by running TLP. By running auto-cpufreq and unbinding the driver for the usb expansion cards, I can get around 6 hours of battery life with maximum charge set at 85%. I have a number of silly Gnome eye candy extensions installed. But even with several open terminals running, multiple Firefox windows, the Teams app running, I’m getting 5-6 hours. I’m sure that someone using a lower resource demanding desktop than Gnome should get longer battery life. So here are the commands I use.

First of all, you will need to find the correct PCI device identifier of the bus. This page provides an excellent description of how to do this.

The following command run as root should return the PCI device identifier for USB devices on your Framework laptop.

find /sys/devices -name "*usb*" | cut -d\/ -f5 | sort | uniq | sort | grep 0000

Here is the output I get for my laptop.

0000:00:0d.0
0000:00:14.0

Now to unbind your USB cards, you just run this command for each identified device. For example.

echo 0000:00:0d.0 | sudo tee /sys/bus/pci/drivers/xhci_hcd/unbind
echo 0000:00:14.0 | sudo tee /sys/bus/pci/drivers/xhci_hcd/unbind

The above two commands add the device id to the unbind file in /sys/bus/pci/drivers/xhci_hcd. The module, xhci_hcd, is the driver for USB devices. Note that once a device id has been added to the unbind file, you will no longer see anything with that id in /sys/devices. With my laptop, once these devices have been added to unbind, bluetooth and fingerprint recognition are disabled. Hdmi and wifi still work, though. To rebind the USB cards, you would simply run these commands.

echo 0000:00:0d.0 | sudo tee /sys/bus/pci/drivers/xhci_hcd/bind
echo 0000:00:14.0 | sudo tee /sys/bus/pci/drivers/xhci_hcd/bind

Your USB devices should work again, including bluetooth. Once you have identified the correct device id, it’s simple to turn the appropriate commands into a bash script. So for a script named disable_usb.sh, you would simply do this.

#!/bin/bash

echo 0000:00:0d.0 | sudo tee /sys/bus/pci/drivers/xhci_hcd/unbind
echo 0000:00:14.0 | sudo tee /sys/bus/pci/drivers/xhci_hcd/unbind

Then do “chmod +x”. If you place the script in /usr/local/bin, you should be able to run this script by doing disable_usb.sh as root or with sudo.

To rebind the usb cards you could create a similar script named enable_usb.sh.

#!/bin/bash

echo 0000:00:0d.0 | sudo tee /sys/bus/pci/drivers/xhci_hcd/bind
echo 0000:00:14.0 | sudo tee /sys/bus/pci/drivers/xhci_hcd/bind

Since you need to know what the bus IDs are for your usb devices on your machine, I can’t think of a simple way to make a script that can simply be run on any Framework computer. However, once you have identified the correct bus ids, it should be easy to modify the above scripts. I have found it much easier to simply run these scripts than manually pulling out my USB cards.

5 Likes

Since I’m not able to add this to my previous post, I’m adding this here in case anyone would like to run the above scripts automatically when the charger is unplugged/plugged. This is based on the information in this link, https://unix.stackexchange.com/questions/321917/executing-code-every-time-a-laptop-is-plugged-into-or-unplugged-from-power, adding this script to /etc/rules.d will unbind USB drivers when the laptop is unplugged and rebind them when it is plugged in.

/etc/udev/rules.d/powersave.rules
SUBSYSTEM=="power_supply", ATTR{online}=="0", RUN+="/usr/local/bin/disable_usb.sh true"
SUBSYSTEM=="power_supply", ATTR{online}=="1", RUN+="/usr/local/bin/enable_usb.sh false"

I have tested the above on my Framework laptop running Fedora 37.

2 Likes

Is there a way to tune down power usage when browsing using Firefox? The battery output wattage is around 11W given two usb-c cards and two usb-a cards, and 9W given two usb-a cards removed.

In addition, besides CPU’s scaling governor, power states, and PSR, are there some other factors that will affect power usage? Such as file system, CPU scheduler, and even how GUI toolkits implement fractional scaling?

I have noticed the system’s power usabe spikes to about 15W+ immediately after boot. Is there a way to lower it?

Is acpi_osi="Windows 2020" still needed for Tigerlake motherboard?

How to get s0ix working?

My setup:
i5-1135G7
2*8GB Crucial DDR4 3200
SK Hynix P41 1TB

Arch Linux
Kernel 6.1.8 (linux)
GNOME 43 + Mutter with Dynamic Triple Buffering patch
Fractional Scaling Enabled, Set to 150%
F2FS on LUKS

TLP Active with following overrides:

CPU_SCALING_GOVERNOR_ON_AC=performance
CPU_SCALING_GOVERNOR_ON_BAT=powersave
CPU_ENERGY_PERF_POLICY_ON_AC=40
CPU_ENERGY_PERF_POLICY_ON_BAT=225
INTEL_GPU_MAX_FREQ_ON_BAT=450
INTEL_GPU_BOOST_FREQ_ON_BAT=450
PCIE_ASPM_ON_AC=performance
PCIE_ASPM_ON_BAT=powersupersave

Kernel parameters:

rw quiet splash rd.luks.name=581ee789-0bd5-43f2-9246-69caae83d6af=lcroot root=/dev/mapper/lcroot rootflags=atgc resume=UUID=05af758b-605d-448a-a8d4-ddc50a1319ed resume_offset=1465344 mem_sleep_default=deep nvme.noacpi=1 rd.luks.options=tpm2-device=auto
2 Likes

In case it helps, with the latest version of Chrome (Version 110.0.5481.77) on Fedora 37, I was only able to get video decoding to work with the following launch arguments:

--ignore-gpu-blocklist
--disable-gpu-driver-bug-workarounds
--enable-accelerated-video-decode
--enable-features=VaapiVideoDecoder,VaapiVideoEncoder
--use-gl=egl
--disable-features=UseChromeOSDirectVideoDecoder

You can add them to the Exec lines of the /usr/share/applications/google-chrome.desktop to ensure those are applied each time you start Chrome via your desktop environment shortcut.

To ensure that this change remains even if your desktop environment is updated, you might need to copy the shortcut like this: cp /usr/share/applications/google-chrome.desktop ~/.local/share/applications

5 Likes

I have set the charge limit setting in my BIOS to 80%, how ever when I check inside Pop OS it reports that the battery is still trying to charge despite already being at 80%. It will also sometimes jump between a time until full, “Discharging”, and “Charging”

image

Do I need to change any settings at the OS level or does it just not understand the BIOS is limiting the charge to 80%? I havent done any tuning yet via powertop.

1 Like

But based on your screenshot it says discharging?

Can you send us a screenshot showing more than 80% and charging?

1 Like