[TRACKING] Linux battery life tuning

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

image

Keeps jumping around. Now it mostly says “Charging”

1 Like

Found a screen with more detail

1 Like

I think you are seeing normal behavior. I’ve seen a few other posts asking about the same thing. I think the “answer” was that the system can draw from the battery in addition to the usb supply during high demand and switch back to charging the battery when the load goes low. A combination of immediate CPU usage and power draw from other system components and usb devices etc.

I suspect also that the charge controller may be switching between modes while “maintaining” a charge.

I think you may be right. I saw it go to “Not Charging” for a little bit. The thing is it still says Discharging/Charging even when Idle. I only had the single browser tab open to make my posts.

Oddly when I did not have the limit set i did not see this behaviour and it was always at Not Charging.

Just want to make sure I am not killing my battery as I will be getting a dock soon and replacing my desktop with the FW. So still learning about proper battery maintenance.

2 Likes

The tool @Fleetscut mentioned (gnome-power-manager) also shows the charge and discharge rates of the battery over time.

This is my battery over the last few hours. Even though gnome also shows “charging” to me (and cycles between ~“nothing” and ~“charging”), the rate is 0 most of the time. There are some spikes in the graph, where my framework might have had some heavy load.

2 Likes

I added it to the wiki post, but I’ll add a comment as well to bump this thread: There is now an official battery optimization guide for Ubuntu. See the link above.

3 Likes

@Morpheus636 Can you please share the link?

It’s in the first post.

2 Likes

I’ve followed that guide, which includes running TLPUI which wasn’t able to actually save the file here. I applied the diff by hand and published a copy of the patch for your convenience, see https://anarc.at/hardware/laptop/framework-12th-gen/tlp.patch

1 Like