Quantcast
Channel: CodeSection,代码区,Linux操作系统:Ubuntu_Centos_Debian - CodeSec
Viewing all articles
Browse latest Browse all 11063

TLP - Don't go chasing power management

$
0
0

Updated: January 9, 2017

AKA The Myth ofPower Management in linux. Today, I am going to talk to you about a sensitive topic. The battery life of your laptop, when eastbound and down, loaded up and running with Linux. Can you extend it? Can you make Linux eat less juice?

Enter TLP, a tool designed to bring you the benefits of advanced power management for the glorious benefit of optimized battery life. It is a command-line utility and it is intended for people with good Linux skills, even though it advertises itself as being approachable even by people who are less than l33t nerds. So let's see what gives shall we?

The story

I am normally skeptical when it comes to tweaks. In general, your performance will be first and foremost limited by your hardware. It's not like software vendors are totally clueless or purposefully crippling systems so you get less than ideal results. On average, default configurations, kernel, software, whatever, are fairly good, designed for most typical workloads, and under normal conditions, they are just as good as any.

I've discussed this to some extent in my thirdLinux cool hacks guide. Changing tunables under /proc and /sys will not create any miracles. On servers, under special conditions, yes, maybe. In your home? Nah. You will not be able to tell the difference, no matter what scheduler or swappiness ratio you choose. Seriously.

Then, there's a tool like TLP, and it promises a lot. It is available for most major distros, and it can help with things like dirty buffer timeouts, Wi-Fi and audio power saving, scheduling, disk spin down, Wake-on-LAN, ALPM, and more. All of this sounds quite fascinating, so I decided totest the utility and check how useful and accessible it really is to the common user. In fact, this is probably the most important piece here, and the one I want to validate. Can normal users truly tap into the power of TLP? And for that matter, do advanced users really need this tool, or can they manually manage their systems in an effective way?

Combat test

I installed TLP onFedora 24, following the online instructions. There are some odd problems here and there, like masking the systemd-rfkill service, which did not seem to work. But starting TLP worked just fine.

sudo systemctl mask systemd-rfkill@.service

Failed to execute operation: Invalid argument

sudo systemctl enable tlp

Once you enable TLP, it will load with the default configuration, which is stored under /etc/default/tlp. Your next step is to examine the file, see the default options, and the slowly start making changes. But if you want to be effective, you will need to do this in a very structured way: 1) keep backups 2) be fully aware of what each option does 3) only make one change at a time 4) reliably measure the difference in your performance and battery life as a result.

To fully gain from TLP without fooling yourself with a nice placebo effect or random luck of your erratic browsing habits, you will need a lot of time, and I doubt most people will be interested in a proper experiment methodology. Second, every setting has its good and bad sides, and you really need to understand what you're doing. Then, you can always check your currently load config with the tlp-stat command:

sudo tlp-stat

--- TLP 0.9 --------------------------------------------

+++ Configured Settings: /etc/default/tlp

TLP_ENABLE=1

TLP_DEFAULT_MODE=AC

DISK_IDLE_SECS_ON_AC=0

DISK_IDLE_SECS_ON_BAT=2

MAX_LOST_WORK_SECS_ON_AC=15

MAX_LOST_WORK_SECS_ON_BAT=60

SCHED_POWERSAVE_ON_AC=0

SCHED_POWERSAVE_ON_BAT=1

NMI_WATCHDOG=0

ENERGY_PERF_POLICY_ON_AC=performance

ENERGY_PERF_POLICY_ON_BAT=powersave

DISK_DEVICES="sda sdb"

+++ PCIe Active State Power Management

/sys/module/pcie_aspm/parameters/policy = default (using bios preferences)

+++ Intel Graphics

/sys/module/i915/parameters/powersave= (not available)

/sys/module/i915/parameters/enable_rc6= 1 (enabled)

/sys/module/i915/parameters/enable_dc= -1 (use per-chip default)

/sys/module/i915/parameters/enable_fbc= 0 (disabled)

I started exploring what each options does and how it affects the system. Just so you know, whatever you choose in the configuration file actually maps to a tunable under /sys, and if you're savvy enough, you can manually play. Do be warned that you could cause damage or inconvenience to yourself if you set a wrong parameter. For example, you can offline your CPU cores, you can delete SATA devices, and so forth. You really need to be careful and confident.

Furthermore, while tweaking, I also installed powertop, and had it running, so I could gage the power consumption. Powertop will also report on your tunables, and whether it thinks they are correctly set up - by correctly, I mean power-friendly.

Moreover, you also need to establish a baseline, and this is quite difficult when running a GUI and using Wireless. The simple geometric positioning of your laptop in relation to the router antenna will determine some of the power bleed. The desktop will also have its own noise, with processes spinning up and down, and your power usage will fluctuate a good percentage without you doing anything significant.


TLP - Don't go chasing power management
TLP - Don't go chasing power management
In a nutshell

There will be four major parameters affecting your battery life, apart from the physical properties of the actual battery. One, CPU utilization. I could probably spend a whole day talking about power management in processors, C states, P states, BIOS firmware, and how the kernel affects this whole thing. But it comes down to - the more power you're using, the more you drain the battery. Base frequency and then how high up and how quickly you go when there are increased workloads.

Two, Wireless - the strength of your signal and the utilization of the antenna. Very dependent on the actual setup. Three, screen brightness. Four, the graphics card, and it could potentially be the chief culprit, depending on your setup. The drain will depend on your usage model first and foremost, not the idle power usage. Everything else is just to keep you busy and happy.

It's all about the drivers

And so we go to the one thing that makes everything tick - the drivers. Your hardware will behave based on how it's configured and how the operating system interfaces with the different components. If your distro does not fully support the hardware stack, you will probably have a sub-optimized power utilization. No matter how diligently you try to improve on the little things, at the end of the day, it's about the big things.


TLP - Don't go chasing power management

So what about drivers? Just think Nouveau vs Nvidia. Think whether the driver set you get on Linux is optimal. Think about certain processor families, especially newer models, not being fully supported on Linux. Think of the various kernel versions. You introduce so much variance through the software stack it becomes very difficult to keep an accurate track of your power drain.

Optimization & examples

Yes, you CAN improve on the current state by potentially tuning the system down to a less aggressive level. But ultimately, the benefits will be far outweighed by thesheer drain through normal activities.

You could tweak your system, but the fine changes are dwarfed by the raw power use when you spin up workloads. For example, my Lenovo Ideapad Y50-70 machine uses about 15W idle, but can spin up to about 115W under

Viewing all articles
Browse latest Browse all 11063

Trending Articles