Battery Life: Idle Power Usage - junaruga/framework-laptop-config GitHub Wiki

This note is to tune idle power usage by PowerTOP and TLP. It is checked on Fedora Linux 35. I referred the Framework community's this thread.

Install

Install PowerTop.

$ sudo dnf install powertop

$ rpm -q powertop
powertop-2.14-2.fc35.x86_64

You see the powertop has a systemd service.

$ rpm -ql powertop | grep systemd
/usr/lib/systemd/system/powertop.service

$ systemctl list-unit-files | grep powertop
powertop.service                                                                    disabled        disabled
$ sudo systemctl enable powertop

$ systemctl -a | grep powertop
  powertop.service                                                                                                                                                   loaded    inactive dead      PowerTOP autotuner

Install TLP. You can see TLP's installation document on Fedora.

$ sudo dnf install tlp tlp-rdw

$ rpm -q tlp tlp-rdw
tlp-1.4.0-2.fc35.noarch
tlp-rdw-1.4.0-2.fc35.noarch

You see the powertop also has a systemd service.

$ rpm -ql tlp | grep systemd
/usr/lib/systemd/system-preset/50-tlp.preset
/usr/lib/systemd/system-sleep
/usr/lib/systemd/system-sleep/tlp
/usr/lib/systemd/system/tlp.service

$ systemctl list-unit-files | grep tlp
tlp.service                                                                         enabled         enabled

Edit /etc/tlp.conf. Add the line PCIE_ASPM_ON_BAT=powersupersave as below.

$ cd /etc

$ sudo cp -p tlp.conf tlp.conf.org

$ sudo vi tlp.conf

$ diff -u tlp.conf.org tlp.conf
--- tlp.conf.org	2021-10-05 17:51:20.000000000 +0200
+++ tlp.conf	2021-12-31 21:53:38.867100574 +0100
@@ -342,6 +342,7 @@

 #PCIE_ASPM_ON_AC=default
 #PCIE_ASPM_ON_BAT=default
+PCIE_ASPM_ON_BAT=powersupersave

 # Runtime Power Management for PCIe bus devices: on=disable, auto=enable.
 # Default: on (AC), auto (BAT)

Note perhaps I should set the setting below to disable USB auto suspend.

USB_AUTOSUSPEND=0
$ sudo systemctl start tlp

$ systemctl status tlp
● tlp.service - TLP system startup/shutdown
     Loaded: loaded (/usr/lib/systemd/system/tlp.service; enabled; vendor preset: enabled)
     Active: active (exited) since Fri 2021-12-31 21:56:04 CET; 4s ago
       Docs: https://linrunner.de/tlp
    Process: 17566 ExecStart=/usr/sbin/tlp init start (code=exited, status=0/SUCCESS)
   Main PID: 17566 (code=exited, status=0/SUCCESS)
        CPU: 145ms

Note I needed to executed the commands below too, as the journalctl -f complained. The tlp conflicts with the power-profiles-daemon. See the first comment on the thread.

$ sudo systemctl mask power-profiles-daemon.service
Created symlink /etc/systemd/system/power-profiles-daemon.service → /dev/null.

$ sudo systemctl mask systemd-rfkill.service
Created symlink /etc/systemd/system/systemd-rfkill.service → /dev/null.

Start PowerTop too.

$ sudo systemctl start powertop

The "Active" status is "inactive (dead)". According to the message "To show power estimates do 337 measurement(s) connected to battery only" and this page, do I need to wait more to get the enough info about the battery?

$ systemctl status powertop
○ powertop.service - PowerTOP autotuner
     Loaded: loaded (/usr/lib/systemd/system/powertop.service; enabled; vendor preset: disabled)
     Active: inactive (dead) since Sun 2022-01-02 15:05:30 CET; 8min ago
    Process: 6680 ExecStart=/usr/sbin/powertop --auto-tune (code=exited, status=0/SUCCESS)
   Main PID: 6680 (code=exited, status=0/SUCCESS)
        CPU: 297ms

Jan 02 15:05:29 fedora powertop[6680]: RAPL device for cpu 0
Jan 02 15:05:29 fedora powertop[6680]: RAPL Using PowerCap Sysfs : Domain Mask d
Jan 02 15:05:29 fedora powertop[6680]: RAPL device for cpu 0
Jan 02 15:05:29 fedora powertop[6680]: RAPL Using PowerCap Sysfs : Domain Mask d
Jan 02 15:05:29 fedora powertop[6680]: Devfreq not enabled
Jan 02 15:05:29 fedora powertop[6680]: glob returned GLOB_ABORTED
Jan 02 15:05:30 fedora powertop[6680]: Leaving PowerTOP
Jan 02 15:05:30 fedora powertop[6680]: To show power estimates do 337 measurement(s) connected to battery only
Jan 02 15:05:30 fedora systemd[1]: powertop.service: Deactivated successfully.
Jan 02 15:05:30 fedora systemd[1]: Finished PowerTOP autotuner.

Check the report

Interactive mode

You can run the powertop with interactive mode like this. The interface is like top command.

$ sudo powertop
PowerTOP 2.14     Overview   Idle stats   Frequency stats   Device stats   Tunables   WakeUp

The battery reports a discharge rate of 7.61 W
The energy consumed was 152 J
The estimated remaining time is 6 hours, 2 minutes

Summary: 1322.2 wakeups/second,  0.0 GPU ops/seconds, 0.0 VFS ops/sec and 16.5% CPU use

                Usage       Events/s    Category       Description
              4.5 ms/s     355.6        Timer          tick_sched_timer
              5.2 ms/s     191.7        Interrupt      [30] i2c_designware.
...

Text (CSV) report

$ cd /path/to/work_dir

$ sudo powertop --csv
modprobe cpufreq_stats failedLoaded 228 prior measurements
RAPL device for cpu 0
RAPL Using PowerCap Sysfs : Domain Mask d
RAPL device for cpu 0
RAPL Using PowerCap Sysfs : Domain Mask d
Devfreq not enabled
glob returned GLOB_ABORTED
Preparing to take measurements
To show power estimates do 129 measurement(s) connected to battery only
Taking 1 measurement(s) for a duration of 20 second(s) each.
PowerTOP outputting using base filename powertop.csv

$ grep '^The battery reports a discharge rate of:' powertop.csv
The battery reports a discharge rate of:  5.72  W;

HTML report

You can get a report from powertop.

$ cd /path/to/work_dir

$ sudo powertop --html
modprobe cpufreq_stats failedLoaded 229 prior measurements
RAPL device for cpu 0
RAPL Using PowerCap Sysfs : Domain Mask d
RAPL device for cpu 0
RAPL Using PowerCap Sysfs : Domain Mask d
Devfreq not enabled
glob returned GLOB_ABORTED
Preparing to take measurements
To show power estimates do 128 measurement(s) connected to battery only
Taking 1 measurement(s) for a duration of 20 second(s) each.
PowerTOP outputting using base filename powertop.html

Check the report.

$ firefox powertop.html

References