Skip to main content

Power Management

Battery Optimisations

Want to check how much power your laptop is consuming on battery ?

sudo powertop

It will open up and you should see something like this:


PowerTOP 2.15     Overview   Idle stats   Frequency stats   Device stats   Tunables   Wake

The battery reports a discharge rate of 18.6 W
The energy consumed was 0.00 J
The estimated remaining time is 2 hours, 43 minutes

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

                Usage       Events/s    Category       Description
            361.1 ms/s     1099.6       Process        [PID 29362] yay -Qu --aur --quiet
              8.6 ms/s     1103.3       Timer          tick_nohz_handler
              3.0 ms/s     669.7        Interrupt      [17] idma64.1
            190.3 ms/s     294.6        Process        [PID 1474] Hyprland
              1.5 ms/s     212.2        kWork          engine_retire
              3.0 ms/s     163.8        Interrupt      [0] HI_SOFTIRQ
              1.3 ms/s     139.1        kWork          intel_atomic_cleanup_work
              0.0 µs/s     139.1        kWork          intel_atomic_commit_work
            341.7 ms/s      0.00        Process        [PID 29358] pacman
              4.3 ms/s     128.1        Process        [PID 550] [irq/95-ELAN1200]
              3.1 ms/s     111.6        Interrupt      [148] i915
            235.8 µs/s     100.6        Timer          intel_uncore_fw_release_timer
              3.0 ms/s      72.3        Timer          timerfd_tmrproc
              0.9 ms/s      67.7        kWork          __intel_wakeref_put_work
             69.1 ms/s       3.7        Process        [PID 29348] powertop
            623.8 µs/s      24.7        Process        [PID 17] [rcu_preempt]
              1.0 ms/s      20.1        Process        [PID 571] [irq/151-iwlwifi]
             42.3 ms/s       1.8        Process        [PID 29375] top
              0.8 ms/s      17.4        kWork          handle_update
             39.6 ms/s       1.8        Process        [PID 29374] top
              0.9 ms/s      14.6        Process        [PID 16] [ksoftirqd/0]
             32.8 ms/s      0.00        Process        [PID 29358] checkupdates
             11.4 ms/s       5.5        Process        [PID 1547] /usr/bin/gjs -m /usr/bin
             61.1 µs/s       9.1        Process        [PID 813] /usr/bin/asusd
              4.5 ms/s       7.3        Process        [PID 26549] /usr/lib/firefox/firefo
              8.8 ms/s       5.5        Process        [PID 15545] /usr/lib/firefox/firefo
             13.8 ms/s       1.8        Process        [PID 15363] alacritty
             13.3 ms/s       1.8        Process        [PID 15596] /usr/lib/firefox/firefo
             14.5 µs/s       6.4        kWork          toggle_allocation_gate
              3.3 ms/s       4.6        Process        [PID 15549] /usr/lib/firefox/firefo
            299.3 µs/s       5.5        kWork          __i915_gem_free_work
              6.4 ms/s       2.7        Interrupt      [7] sched(softirq)
             13.1 ms/s      0.00        Process        [PID 597] [kworker/u49:2]
             11.9 ms/s      0.00        Process        [PID 29359] checkupdates
             60.0 µs/s       4.6        kWork          psi_avgs_work
             42.2 µs/s       4.6        kWork          delayed_vfree_work
              6.9 ms/s       1.8        Process        [PID 15656] /usr/lib/firefox/firefox

Here you need to go in tunables. If you see bad status means linux is constantly supplying power to those pci/usb related hardwares.

It will look something like this,


  Bad           VM writeback timeout
   Bad           Enable Audio codec power management
>> Bad           VM writeback timeout                                                                                   
   Bad           Enable Audio codec power management
   Bad           NMI watchdog should be turned off
   Bad           Autosuspend for USB device N-KEY Device [ASUSTeK Computer Inc.]
   Bad           Runtime PM for port ata1 of PCI device: Intel Corporation Cannon Lake Mobile PCH SATA AHCI Controller
   Bad           Runtime PM for PCI Device Realtek Semiconductor Co., Ltd. RTL8111/8168/8211/8411 PCI Express Gigabit Ethernet
   Bad           Runtime PM for PCI Device Intel Corporation Cannon Lake Mobile PCH SATA AHCI Controller
   Bad           Runtime PM for disk sda
   Bad           Runtime PM for PCI Device Intel Corporation HM470 Chipset LPC/eSPI Controller
   Bad           Runtime PM for PCI Device NVIDIA Corporation TU106M [GeForce RTX 2070 Mobile]
   Bad           Runtime PM for PCI Device Intel Corporation Cannon Lake PCH Shared SRAM
   Bad           Runtime PM for PCI Device Intel Corporation Cannon Lake PCH Thermal Controller
   Bad           Runtime PM for PCI Device Intel Corporation Cannon Lake PCH USB 3.1 xHCI Host Controller
   Bad           Runtime PM for PCI Device Intel Corporation Cannon Lake PCH CNVi WiFi
   Good          Bluetooth device interface status
   Good          Enable SATA link power management for host0
   Good          Runtime PM for I2C Adapter i2c-3 (i915 gmbus dpd)

The "Bad" entries in the Tunable section of powertop indicate power management features that are not enabled or optimized, which could lead to higher power consumption. You can fix these issues by enabling the relevant power-saving features.

So I fixed it by doing these commands:

To fix all these issues, I ran these commands

1. Fix VM Writeback Timeout:

VM writeback timeout controls how often dirty data in memory is written to disk. A higher timeout can save power because it reduces disk activity.

sudo bash -c 'echo 1500 > /proc/sys/vm/dirty_writeback_centisecs'\n

2. Enable Audio Codec Power Management:

Audio codecs can stay powered up even when they are not being used, wasting power. Enabling audio codec power management can save power.

sudo bash -c 'echo 1 > /sys/module/snd_hda_intel/parameters/power_save'\n

3. Turn Off NMI Watchdog:

The NMI watchdog is used for debugging purposes and can consume power. If you don't need it, it's safe to turn it off.

sudo bash -c 'echo 0 > /proc/sys/kernel/nmi_watchdog'\n

4. Enable USB Autosuspend for Devices:

To allow USB devices like your keyboard (N-KEY device) to go into low-power mode when not in use, you can enable autosuspend.

To enable autosuspend for USB devices:

for device in /sys/bus/usb/devices/*/power/control; do echo "auto" | sudo tee $device; done

5. Enable Runtime Power Management (PM) for PCI Devices:

Power management for PCI devices (such as your NVIDIA GPU, SATA controller, Ethernet controller, etc.) is currently disabled. Enabling runtime PM allows these devices to be powered down when not in use.

To enable runtime power management for PCI devices, you can use:

for device in /sys/bus/pci/devices/*/power/control; do echo "auto" | sudo tee $device; done

Alternatively, if you know the specific devices you want to target (such as the NVIDIA GPU or SATA controller), you can enable power management for individual devices. For example, to enable runtime PM for the NVIDIA GPU:

echo "auto" | sudo tee /sys/bus/pci/devices/0000:01:00.0/power/control

Replace 0000:01:00.0 with the correct PCI address for your GPU (which you can get from lspci).

6. Enable Runtime PM for Disk:

Your disk sda is not using runtime power management. Enabling power management will reduce power consumption when the disk is idle.

To enable runtime PM for the disk:

sudo bash -c 'echo "min_power" > /sys/class/scsi_host/host0/link_power_management_policy'

And finally set governor to powersaver

sudo cpupower frequency-set -g powersave

Set manual cpu frequency

sudo cpupower frequency-set -u 1.6GHz

Warning PLEASE check and verify these commands befre running them blindly.