Tweaking TLP

Posted on Feb 25, 2024

Problem

Linux battery life on laptops is known to not be great; If you are a student or travel frequently you will want that your machine lasts some time.

Solution

There are many things one can do to improve battery life:

  1. Lower screen brightness
  2. Turn off keyboard backlight
  3. Turn off Bluetooth
  4. Turn off Wifi
  5. Use resource efficient software
  6. Use the appropriate drivers for your system

But I am going to focus on TLP, a power management tool which will allow us to optimize the battery usage on Linux.

Installation

Install tlp, tlp-rdw and smartmontools to get everything you need for tlp. For monitoring power consumption, I recommend powertop.

Enable the tlp service and use tlp-stat to ensure everything is running OK.

Tweaks

Now, onto the good stuff :)

In the TLP settings documentation (https://linrunner.de/tlp/settings/introduction.html) it is provided a healthy amount of information that we can use to configure a Linux machine to use the battery in the way that we wish.

We are partircularly interested in optimizing the battery life of the machine; there is some documentation available at https://linrunner.de/tlp/support/optimizing.html

Obviously I am not going to cover all of those configuration options; Rather I am focusing particular to my system, encouraging you to do the same (not just copy and paste settings). Remember: Always test the settings to check if they yield the desired results.

An important aspect to know is your CPU, as this will affect some options; Use lscpu to check what you are using. Then you can search on the documentation about your specific case.

Another tip is to check powertop’s “Tunables” section (press TAB 4 times); Here you can find devices and settings which may not have been optimized by default using TLP. In my case I had: “Bad VM writeback timeout”. This is a kernel parameter which can be set by sysctl, but TLP can do the same just by editing the config file (/etc/tlp.conf) and changing:

MAX_LOST_WORK_SECS_ON_BAT=15

This is just an example to illustrate how we would proceed to optimize a machine.

In the documentation there are some more concrete settings we can apply in TLP:

CPU_ENERGY_PERF_POLICY_ON_BAT=power
PLATFORM_PROFILE_ON_BAT=low-power
CPU_BOOST_ON_BAT=0
CPU_HWP_DYN_BOOST_ON_BAT=0
CPU_MAX_PERF_ON_BAT=nn # intel_pstate driver; nn < 100

It is highly recommend to TEST EACH ONE, and see if the power consumption is affected (in powertop) and if it performs as expected; Also check if fans are running as intended and the CPU is not throttling.