Would you like to greatly increase the autonomy of your PC under Linux?

That’s good, because I just read an interesting article written by Hayden James which presents the optimization of the battery life on Linux laptops thanks to TLP. With his config to small onions, Hayden managed to increase the autonomy of his ThinkPad from 6-8h to more than 10 hours and following his explanations you will be able to do the same.

TLP (Tuning Linux POwer) is therefore a Linux tool capable of optimizing the feeding of recent portable computers, all without complex configuration. Unlike his predecessor Laptop Mode Tools (LMT), TLP applies by default many recommendations for Powertop (Intel analysis tool) to save energy. TLP runs in the background And once installed, knows how to automatically adjust dozens of system parameters to reduce consumption (fine processor management, discs, network, GPU, etc.).

Here’s how to install TLP:

# Ubuntu/Debian/Mint/Pop!_OS
sudo apt install tlp cpufrequtils

# Fedora/CentOS/RHEL
sudo dnf install tlp cpufrequtils

# Arch Linux et dérivés
sudo pacman -S tlp tlp-rdw

Then, to activate it, nothing could be simpler:

# Activation du service
sudo systemctl enable tlp.service
sudo systemctl mask systemd-rfkill.service
sudo systemctl mask systemd-rfkill.socket
sudo systemctl restart tlp.service

There is also the part concerning the configuration of the CPU for AMD laptops. Type processors AMD Ryzen / Zen have new frequency management and tension options that TLP allows you to operate to save energy without sacrificing performance too much. I don’t know for Intel, but I think it must be equivalent. I am thinking for example of piloting Dthe governors Who are algorithms that decide at what level of frequency the CPU must turn according to the load. This specific point that we dwell on it, because this is where a good part of the magic of energy saves is played out.

The governor “Ondemand” (the one used in the mains) works according to a fairly brutal but effective logic: as soon as he detects a CPU load which exceeds a certain threshold (typically 80%), it immediately pushes the frequency to the maximum. Then, if the load decreases, it gradually reduces the frequency by stages. It is as if your CPU was a Formula 1 pilot that crushes the accelerator as soon as he sees a straight line, then lifts his foot gradually when turns.

The “conservative” governor (the one we prefer when you are on battery) is much more patient: instead of going directly to maximum speed, it increases the level level frequency by landing, and only if the load remains high on several consecutive samples (generally between 100 and 500ms according to the Kernel config). It also checks more often if it can reduce the frequency. There, it is rather an economical driver who gently accelerates and anticipates slowdowns to preserve his fuel.

Suddenly, in concrete terms, if you type a text in your favorite editor with active Ondemand, each strike can trigger a 3-4GHz peak while with the active conservative mode, the CPU may go up only to 1.2GHz then 1.8GHz if necessary. On modern processors, this difference easily represents 3 to 8W less consumption in daily tasks, or 30-60 minutes of additional autonomy on a typical day. Had to think about it !!

Do not forget the activation of the mode either amd-pstate which in passive mode allows the CPU to go down to frequencies idle Lower (approximately 400 MHz) and deactivates the “Turbo Core” boost & mldr; This reduces consumption at rest. Be careful, however, it can also impact the perfs of your PC so it’s up to you to see how you dose all this.

And for AMD GPUs, it’s the same with standby management and perfs via DPM (Dynamic Power Management) pilot AMDGPU. It is once again TLP that takes care of everything. However, be careful for Linux laptops owners who have an NVIDIA card, it can benefit a lot of TLP, but will likely require a specific additional configuration.

In addition, the longevity of a lithium-ion battery does not only depend on its immediate use, but also on the way it is Loaded and discharged over time. For this, TLP incorporates functions of “Battery Care”Which allow you to intelligently manage the load for Minimize chemical wear battery. I am thinking for example of the maintenance of the battery in a partial load beach located between 20 and 80%, therefore a configuration of load profiles according to the use you have of your PC (traveler, sedentary & mldr; etc).

Well, now that TLP is installed in your home and purrs in the background, let’s move on to serious things, namely the config that will transform your laptop into a marathoner of autonomy.

In terms of functioningTLP uses a configuration file (/etc/tlp.conf) where each parameter can be adjusted. By default, without changing anything, it already offers an aggressive “energy saving” profile on battery (and a more efficient profile in mains), suitable for most machines.

Be careful anyway, All features (especially battery charging thresholds) are not supported by all laptops. So find out before. Here is the recommended config according to Hayden, to adapt of course to your equipment:

# Configuration CPU
CPU_DRIVER_OPMODE_ON_AC=passive
CPU_DRIVER_OPMODE_ON_BAT=passive
CPU_SCALING_GOVERNOR_ON_AC=ondemand
CPU_SCALING_GOVERNOR_ON_BAT=conservative
CPU_BOOST_ON_AC=1
CPU_BOOST_ON_BAT=0

# Profils plateforme
PLATFORM_PROFILE_ON_AC=balanced
PLATFORM_PROFILE_ON_BAT=low-power

# GPU AMD
RADEON_DPM_PERF_LEVEL_ON_AC=auto 
RADEON_DPM_PERF_LEVEL_ON_BAT=low

# Gestion batterie
START_CHARGE_THRESH_BAT0=50 
STOP_CHARGE_THRESH_BAT0=80

And to check that everything works well, here are the commands that TLP offers:

# Vérification du statut
sudo tlp-stat -p # Profils disponibles
sudo tlp-stat -b # Infos batterie
sudo tlp-stat -s # Statut général

You will see, it’s like going from a hummer that consumes a Toyota Prius. And do not forget to reduce the brightness of your screen and use a light office environment like XFCE, LXDE or Mate and to control all the processes and services that turn in the background as updates, file indexing, Cloud & MLDR synchro; which could eat the battery little by little. On battery, he is also wise to close unused applications Rather than leaving them minimized if they consume CPU.

For example, close a browser left with active tabs will prevent it from using the CPU in the background.

Tools like top will help you locate processes that consume CPU or wake him up frequently. Moreover, TLP already helps by reducing the CPU frequency and putting certain devices in autosuspend, but it cannot close the programs for you. Also think of Disable start -up services that you do not use (for example the print service, the local web server, etc. if they are not necessary).

Moreover, Cut Bluetooth, Wi-Fi Or any radio component when you don’t need it can gain some % battery.

In short, by combining all these tips, you can create a environment conducive to energy savings. And using TLP which will be by your side to manage the equipment optimally, and some good practices (close unnecessary apps, lower the brightness, use a light office, maintain load thresholds), you will be at the cleat on the autonomy of your Linux computer. You can even for the most bearded of you, make you a small shell script to switch your TLP config between a ‘ultra-economy’ and fashion ‘mode’ mode according to your needs.

So what are you waiting for to boost the autonomy of your Linux laptop? In any case, a big thank you to Hayden James for this highlighting of TLP!


Source link

Categorized in: