Skip to content

kernel/cpu power

This is intended as a way to document how to apply cpu power limits to AMD Ryzen CPUs.

power-profiles-daemon

  • powerprofilesctl Show current status
  • powerprofilesctl set power-saver Change mode to power-saver
  • powerprofilesctl list-actions List all possible actions and their status
  • powerprofilesctl configure-action amdgpu_dpm --enable Enable amdgpu_dpm action
  • powerprofilesctl configure-battery-aware --disable Disable dynamic changes on battery status change.

TLP says TLP is better

amd_pstate

  • ls /sys/devices/system/cpu/cpufreq/policy0/*amd*
  • echo 0 > /sys/devices/system/cpu/cpufreq/policy*/boost Disable boost
  • for i in /sys/devices/system/cpu/cpufreq/policy{0..15}/scaling_max_freq ; do echo 3500000 > $i ; done Set max freq to 3.5GHz
  • for i in /sys/devices/system/cpu/cpufreq/policy{0..15}/scaling_min_freq ; do echo 400000 > $i ; done Set min freq to 400MHz
  • for i in /sys/devices/system/cpu/cpu{1,3,5,7,8,9,10,11,12,13,14,15}/online; do echo 0 > $i ; done Power off cores
  • cat /sys/devices/system/cpu/online Check online cores
  • while : ; do : ; done Put load on a single thread.
  • ``

Manual tunning

  • ``
  • ``
  • ``
  • ``
  • ``
  • ``

Shutting down cores. CPU hotplug

Core 0 can not be shutted down as some architectures may have some special dependency on a certain CPU.

echo 0 | sudo tee /sys/devices/system/cpu/cpu4/online

Possible states

cat /sys/devices/system/cpu/hotplug/states

Change a target

echo 140 > /sys/devices/system/cpu/cpu4/hotplug/target

CPU governor

List governors

sudo cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors

Set governor

echo performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor

Interrupts

cat /proc/interrupts

stats

cat /proc/stat
---
cpu  863551 3429 857793 8085941 31541 33767 19313 0 33353 0

Meaning:

  • user: normal processes executing in user mode
  • nice: niced processes executing in user mode
  • system: processes executing in kernel mode
  • idle: twiddling thumbs
  • iowait: In a word, iowait stands for waiting for I/O to complete. But there are several problems:
  • Cpu will not wait for I/O to complete, iowait is the time that a task is waiting for I/O to complete. When cpu goes into idle state for outstanding task io, another task will be scheduled on this CPU.
  • In a multi-core CPU, the task waiting for I/O to complete is not running on any CPU, so the iowait of each CPU is difficult to calculate.
  • The value of iowait field in /proc/stat will decrease in certain conditions. So, the iowait is not reliable by reading from /proc/stat.
  • irq: servicing interrupts
  • softirq: servicing softirqs
  • steal: involuntary wait
  • guest: running a normal guest
  • guest_nice: running a niced guest

  • https://www.kernel.org/doc/Documentation/filesystems/proc.txt

tools

  • powertop power consumption and power management diagnosis tool.
  • cpupower Shows and sets processor power related values