Skip to content

Instantly share code, notes, and snippets.

@marcwittke
Created April 26, 2020 20:05
Show Gist options
  • Save marcwittke/e4b951c47ed29ee9ce4eda9cf0064b33 to your computer and use it in GitHub Desktop.
Save marcwittke/e4b951c47ed29ee9ce4eda9cf0064b33 to your computer and use it in GitHub Desktop.
Linux Power Management

CPU Frequency

Monitor CPU Frequency

watch -n 1 cat /proc/cpuinfo | grep "MHz"

List available CPU Frequency Governors

cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governor

Show current CPU Frequency Governor

cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor

Activate a specific CPU Frequency Governor

echo performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor sudo cpupower frequency-set -g powersave sudo cpufreq-set -g powersave

Energy Performance Preference

List available Energy Performance Preferences

cat /sys/devices/system/cpu/cpu0/cpufreq/energy_performance_available_preferences

performance                    # more performance, less energy saving
balance_performance            #        
balance_power [default]        #
power                          # less performance, more energy saving

Show current Energy Performance Preference

cat /sys/devices/system/cpu/cpu0/cpufreq/energy_performance_preference

Activate a specific Energy Performance Preference

echo performance | sudo tee /sys/devices/system/cpu/cpu0/cpufreq/energy_performance_preference sudo x86_energy_perf_policy performance

CPU undervolting

See https://github.com/tiziw/iuvolt

iuvolt configuration

cat /etc/iuvolt.cfg 
voltages=(-170 -140 -85 -170)

iuvolt as system service

systemctl status iuvolt
● iuvolt.service - Undervolt cpu
   Loaded: loaded (/etc/systemd/system/iuvolt.service; enabled; vendor preset: enabled)
   Active: inactive (dead) since Sun 2020-04-26 16:38:17 -03; 18min ago
 Main PID: 9663 (code=exited, status=0/SUCCESS)

abr 26 16:38:17 mw-lat5591 iuvolt[9663]: Loaded config! CPU Core : -170mV, GPU : -140mV, Cache : -85mV, Uncore : -170mV,
abr 26 16:38:17 mw-lat5591 iuvolt[9663]: wrote 0x80000011EA400000 successful to plane index 0
abr 26 16:38:17 mw-lat5591 iuvolt[9663]: wrote 0x80000111EE200000 successful to plane index 1
abr 26 16:38:17 mw-lat5591 iuvolt[9663]: wrote 0x80000211F5200000 successful to plane index 2
abr 26 16:38:17 mw-lat5591 iuvolt[9663]: wrote 0x80000311EA400000 successful to plane index 3

Automated AC/Battery switching via tlp

# sudo tlp-stat
+++ Configured Settings: /etc/default/tlp
TLP_ENABLE=1
TLP_DEFAULT_MODE=BAT
TLP_PERSISTENT_DEFAULT=0
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
CPU_SCALING_GOVERNOR_ON_AC=powersave
CPU_SCALING_GOVERNOR_ON_BAT=powersave
CPU_HWP_ON_AC=balance_power
CPU_HWP_ON_BAT=balance_power
CPU_MIN_PERF_ON_AC=0
CPU_MAX_PERF_ON_AC=100
CPU_MIN_PERF_ON_BAT=0
CPU_MAX_PERF_ON_BAT=33
CPU_BOOST_ON_AC=1
CPU_BOOST_ON_BAT=0
SCHED_POWERSAVE_ON_AC=0
SCHED_POWERSAVE_ON_BAT=1
NMI_WATCHDOG=0
ENERGY_PERF_POLICY_ON_AC=balance-power
ENERGY_PERF_POLICY_ON_BAT=power
DISK_DEVICES="nvme0n1 sda"
DISK_APM_LEVEL_ON_AC="254 254"
DISK_APM_LEVEL_ON_BAT="128 128"
SATA_LINKPWR_ON_AC="med_power_with_dipm max_performance"
SATA_LINKPWR_ON_BAT="med_power_with_dipm min_power"
AHCI_RUNTIME_PM_TIMEOUT=15
INTEL_GPU_MIN_FREQ_ON_AC=350
INTEL_GPU_MIN_FREQ_ON_BAT=350
INTEL_GPU_MAX_FREQ_ON_AC=1150
INTEL_GPU_MAX_FREQ_ON_BAT=1150
INTEL_GPU_BOOST_FREQ_ON_AC=1150
INTEL_GPU_BOOST_FREQ_ON_BAT=1150
RADEON_POWER_PROFILE_ON_AC=low
RADEON_POWER_PROFILE_ON_BAT=mid
RADEON_DPM_STATE_ON_AC=battery
RADEON_DPM_STATE_ON_BAT=battery
RADEON_DPM_PERF_LEVEL_ON_AC=auto
RADEON_DPM_PERF_LEVEL_ON_BAT=auto
WIFI_PWR_ON_AC=off
WIFI_PWR_ON_BAT=on
WOL_DISABLE=Y
SOUND_POWER_SAVE_ON_AC=0
SOUND_POWER_SAVE_ON_BAT=1
SOUND_POWER_SAVE_CONTROLLER=Y
BAY_POWEROFF_ON_AC=0
BAY_POWEROFF_ON_BAT=0
BAY_DEVICE="sr0"
RUNTIME_PM_ON_AC=on
RUNTIME_PM_ON_BAT=auto
USB_AUTOSUSPEND=1
USB_BLACKLIST="0bda:0411 0bda:8153 05e3:0"
USB_BLACKLIST_BTUSB=0
USB_BLACKLIST_PHONE=1
USB_BLACKLIST_PRINTER=1
USB_BLACKLIST_WWAN=1
USB_AUTOSUSPEND_DISABLE_ON_SHUTDOWN=1
RESTORE_DEVICE_STATE_ON_STARTUP=0
DEVICES_TO_DISABLE_ON_STARTUP=""
DEVICES_TO_DISABLE_ON_BAT_NOT_IN_USE="bluetooth wifi"
NATACPI_ENABLE=1
TPACPI_ENABLE=1
TPSMAPI_ENABLE=1
DEVICES_TO_DISABLE_ON_LAN_CONNECT="wifi"
DEVICES_TO_ENABLE_ON_LAN_DISCONNECT="wifi"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment