The Linux Kernel can manage power consumption of the hardware it controls through various knobs.
There are a few popular tools which configure the Kernel appropriately to save power e.g. on a laptop running on battery.
This article is about power when running, there is another one about suspend.
Like any such thing, it's much easier (and fun) to optimize something you can actually measure.
One way to do this is using GNOME's Power Statistics GUI. You can install it using e.g. sudo dnf install gnome-power-manager
(source). Clicking e.g. on Laptop battery on the left will show you the current Rate. The Energy when full -VS- Energy (design) will show you how your "new" battery still is (they degrade over time). (upower --dump
can show some similar information on the CLI.) On the History tab,the Graph type: Time to empty (for a given Data length: N hours) lets you see the predicted battery time remaining; this graph view over time gives a better view than the single "snapshot in time" remaining duration shown on the Power section in the GNOME Setings.
batstat is a similar tool for the CLI, and powerstat, which can be easily installed on Fedora using Snap is another such tool. (It focuses on measuring power consumption while a laptop is on battery; when plugged in it will refuse to start, saying: "Device is not discharging, cannot measure power usage. Perhaps re-run with -z (ignore zero power) or -R (RAPL)". Run it WITHOUT sudo
, as with it it failed with _socket failed: errno=1 (Operation not permitted)`, for me.)
To automatically switch Power Settings from Performance to Balanced or Power Saver when on Battery,
install the GNOME power-profile-switcher
extension
(see GitHub, and a related article).
TODO To automate CPU speed & power further than performance/balanced/safer, consider using https://github.com/AdnanHodzic/auto-cpufreq?
TODO, clarify: I used to use this on a Laptop, but ended up removing it, and going back to power-profiles-daemon
because it seemed to prevent max. CPU frequency even when plugged in and under heavy load?
TLP is easy to install on many Linux distros:
dnf install tlp
dnf remove power-profiles-daemon
sudo systemctl enable --now tlp.service
I've decided not to install / use the Radio Device Wizard (tlp-rdw
) and keep that manual.
TLPUI can be installed via Flatpack to make tweaks later.
sudo cpupower frequency-info
cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
sudo cpupower frequency-set --governor performance
sudo cpupower frequency-set --governor powersave
Intel:
sudo dnf install igt-gpu-tools
sudo intel_gpu_top
NVIDIA:
sudo dnf install nvtop
nvtop
- https://www.linrunner.de/tlp/faq/battery.html
- https://linrunner.de/tlp/settings/battery.html
- https://extensions.gnome.org/extension/4798/thinkpad-battery-threshold/
- https://extensions.gnome.org/extension/5724/battery-health-charging/
The Power Saver / Balanced / Performance that is available e.g. in GNOME out-of-the-box e.g. since Fedora 35 from the menu in the upper right hand corner of the screen and in GNOME Settings > Power uses the power-profiles-daemon (over D-Bus) to set these. It's also available on the CLI as powerprofilesctl
.
These are relatively "coarse grained" profiles - and require a user to remember to manually change them when going on and off charging - which is not ideal. (It would, of course, be possible to script automate this with home made scripts.) They interfere with TLP, and we've disabled them during the installation of TLP above.
powertop shows which processes and Kernel events consume power. (The total Watts is also shown on the Device Info tab.) sudo powertop --html=report.html
produces a HTML report which can be easily shared.
After sudo powertop --calibrate
, or just running for a while, Power Estimates in Watt will start to show up.
It has a Tunables section which recommendations for PCIe devices. Changes made there do not persist over a reboot, but it's possible to launch powertop --auto-tune
at every system boot, e.g. with systemd. Powertop is not aware of if the laptop runs on battery or not.
TLP fixes Powertop's Tunables recommendations (ignore the VM writeback timeout).
fatrace comes with power-usage-report
which provides similar information to powertop
but as CSV.
The https://github.com/rickysarraf/laptop-mode-tools, also documented e.g. on https://wiki.archlinux.org/title/Laptop_Mode_Tools, are an alternative to TLP.
It's older than TLP, has less Stars on GitHub, and no Fedora package.
Probably not required / useful anymore with the intel_pstate
driver.
https://github.com/konkor/cpufreq looks neat - but it's manual; automation with power-profile-switcher
and auto-cpufreq
is better!