在 Linux 6.3 后,加入了更有效率的 amd_pstate_epp
scaling driver, 此文章记录如何进行频率调节以及驱动的使用。
Please note that the scaling driver is different than the CPU governor (e.g. powersave, performance, ondemand, schedulutil, etc.). IMHO, the easiest way to set CPU governor, is to install cpupower, enable the cpupower systemd service, and edit the /etc/default/cpupower file, but there are many ways to do this!
EPP (Energy Performance Preference) 有两种主要参数:
/sys/devices/system/cpu/cpu*/cpufreq/energy_performance_preference
: 当前偏好/sys/devices/system/cpu/cpu[N]/cpufreq/energy_performance_available_preferences
: 可用值
cpupower 的配置文件: /etc/default/cpupower
常用命令
cpupower frequency-info
cat /sys/devices/system/cpu/cpu*/cpufreq/energy_performance_preference
cat /sys/devices/system/cpu/cpu0/cpufreq/energy_performance_available_preferences
# 设置 EPP Hint
echo "balance_power" | tee /sys/devices/system/cpu/cpu*/cpufreq/energy_performance_preference
若出现 Device or resource busy, 则是因为你的 governor 设置成了 performance
开机调整
[Unit]
Description=Set energy performance preference
Wants=multi-user.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/bash -c 'cpupower -g powersave; for i in /sys/devices/system/cpu/cpu*/cpufreq/energy_performance_preference; do echo "balance_power" > "$i"; done'
[Install]
WantedBy=multi-user.target