As I stated in my previous post I recently bought a new laptop, a Clevo PA70ES. It's quite a power hungry beast when running on maximum settings. In this post I'll be taking you through the optimisations I've done to enable this laptop to run off of the battery for a reasonable amount of time.
The first obvious avenue is underclocking the CPU. For this there's an utility called intel-undervolt which you can just emerge on gentoo.
After a bit of playing around I ended up with the following settings in my /etc/intel-undervolt.conf:
undervolt 0 'CPU' -100 undervolt 1 'GPU' -50 undervolt 2 'CPU Cache' -100 undervolt 3 'System Agent' 0 undervolt 4 'Analog I/O' 0
Another obvious avenue is the monitor brightness. To allow the drivers to control the brightness, I had to add the following parameters to my kernel command line: acpi_osi="!Windows 2015" i915.enable_dpcd_backlight=1 . After that setting the brightness worked flawlessly.
With that configured, and intel-undervolt-loop added to my runlevel, I went on to configure two scripts to enable powersaving in KDE. Since we'll be modifying system properties these scripts will need root access, so you will have to create them add them to /etc/sudoers like so:
touch /bin/cpu_fast touch /bin/cpu_powersave chmod +x /bin/cpu_fast /bin/cpu_powersave nano /etc/sudoers ALL ALL=NOPASSWD: /bin/cpu_fast,/bin/cpu_powersave
The first script /bin/cpu_powersave calls /bin/bus_powersave, more on that later. It's main benefit is that also underclocks the CPU and enables laptop_mode. I disable a few cores - but this only results in minimal power savings and can be left out.
#!/bin/bash sudo /bin/bus_powersave sudo cpupower frequency-set -u 800MHz sudo cpupower frequency-set -g powersave echo 20 | sudo tee /sys/devices/system/cpu/intel_pstate/max_perf_pct echo 20 | sudo tee /sys/devices/system/cpu/intel_pstate/min_perf_pct echo 1 | sudo tee /sys/devices/system/cpu/intel_pstate/no_turbo echo 0 | sudo tee /sys/devices/system/cpu/cpu11/online echo 0 | sudo tee /sys/devices/system/cpu/cpu10/online echo 0 | sudo tee /sys/devices/system/cpu/cpu9/online echo 0 | sudo tee /sys/devices/system/cpu/cpu8/online echo 0 | sudo tee /sys/devices/system/cpu/cpu7/online echo 0 | sudo tee /sys/devices/system/cpu/cpu6/online echo 0 | sudo tee /sys/devices/system/cpu/cpu5/online echo 0 | sudo tee /sys/devices/system/cpu/cpu4/online echo 1 | sudo tee /proc/sys/vm/laptop_mode echo 350 | sudo tee/sys/devices/pci0000:00/0000:00:02.0/drm/card0
The /bin/bus_powersave script is more interesting. I ran "sudo powertop" using the following tool: PowerTOP. This displays a set of suggestions of which settings to enable. I simply created a bash script that loops through these devices and enables power management for each of these devices individually:
The last few lines were then added to enable the hard-disks ( SSD ) to rest between writes. This allows the laptop to conserve a little power by simply shutting them off while they're not in use.
#!/bin/bash for i in $(ls /sys/bus/usb/devices | grep -o "[0-9]-[0-9]*" | uniq);do if [ "$(cat /sys/bus/usb/devices/$i/bDeviceClass 2>&1)" != "00" ] && #don't turn off the mouse/keyboard automatically [ -f "/sys/bus/usb/devices/$i/power/control" ]; then echo 'auto' >/sys/bus/usb/devices/$i/power/control fi done #enable power management for all i2c pci and block devices for i in $( ls /sys/bus/i2c/devices/*/device/power/control); do echo 'auto' > $i done for i in $( ls /sys/bus/pci/devices/*/power/control); do echo 'auto' > $i done for i in $( ls /sys/bus/pci/devices/*/*/power/control); do echo 'auto' > $i done for i in $( ls /sys/block/*/device/power/control); do echo 'auto' > $i done for i in $( ls /sys/class/scsi_host/*/link_power_management_policy); do echo 'min_power' > $i done echo '3000' > /proc/sys/vm/dirty_writeback_centisecs echo "3000" > /proc/sys/vm/dirty_expire_centisecs echo "80" > /proc/sys/vm/dirty_ratio echo "20"> /proc/sys/vm/dirty_background_ratio echo '0' > /proc/sys/kernel/nmi_watchdog
All in all, this got my power usage down to about 19w with the Intel internal GPU, the monitor on low and the CPU down-clocked. Pretty decent for a gaming laptop. This just leaves the script to re-enable everything and make the laptop run faster on AC again:
#!/bin/bash sudo cpupower frequency-set -u 4100MHz sudo cpupower frequency-set -g performance echo 100 | sudo tee /sys/devices/system/cpu/intel_pstate/max_perf_pct echo 20 | sudo tee /sys/devices/system/cpu/intel_pstate/min_perf_pct echo 0 | sudo tee /sys/devices/system/cpu/intel_pstate/no_turbo echo 1 | sudo tee /sys/devices/system/cpu/cpu11/online echo 1 | sudo tee /sys/devices/system/cpu/cpu10/online echo 1 | sudo tee /sys/devices/system/cpu/cpu9/online echo 1 | sudo tee /sys/devices/system/cpu/cpu8/online echo 1 | sudo tee /sys/devices/system/cpu/cpu7/online echo 1 | sudo tee /sys/devices/system/cpu/cpu6/online echo 1 | sudo tee /sys/devices/system/cpu/cpu5/online echo 1 | sudo tee /sys/devices/system/cpu/cpu4/online echo 1 | sudo tee /sys/devices/system/cpu/cpu3/online echo 0 | sudo tee /proc/sys/vm/laptop_mode echo 1100 | sudo tee/sys/devices/pci0000:00/0000:00:02.0/drm/card0
That's it, with these modifications this laptop can run ~4-5 hours on a single charge. I hope you enjoyed this quick write-up about Linux power management.