笔者在《Ubuntu监控及调整CPU频率》一文中发现Ubuntu 20.04下Intel i9-10980XE的CPU电源管理策略只有powersave和performance,感觉颇为诡异。而且powersave模式下有计算任务时CPU频率也并非保持在最低频率下运行,而是比最大频率4.8GHz低一点的4.1xGHz-4.2GHz,颇为困惑。
使用:
1 |
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors |
查看可用的governor只有powersave和performance。
使用:
1 |
grep . /sys/devices/system/cpu/cpufreq/policy*/scaling_driver |
查看scaling_driver是用的intel_pstate。
使用:
1 2 3 4 5 6 7 8 |
# cpufreq-set -g ondemand Error setting new values. Common errors: - Do you have proper administration rights? (super-user?) - Is the governor you requested available and modprobed? - Trying to set an invalid policy? - Trying to set a specific frequency, but userspace governor is not available, for example because of hardware which cannot be set to a specific frequency or because the userspace governor isn't loaded? |
直接报错。
根据参考文档1的说法:
其给出的方法看着不太对。参考文档2的说法更加正确:
The Intel_pstate CPU frequency scaling driver has included a passive mode for some time now. In that mode the scaling driver is called intel_cpufreq, and it has all of the same governors as acpi-cpufreq.
参考文档2给出了一个acpi-cpufreq的例子:
查看intel_pstate driver的设置:
1 2 |
# cat /sys/devices/system/cpu/intel_pstate/status active |
将其修改为被动模式:
1 2 3 4 |
# echo passive | sudo tee /sys/devices/system/cpu/intel_pstate/status passive # cat /sys/devices/system/cpu/intel_pstate/status passive |
此时再查看可用的scaling_available_governor就都出来了:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# grep . /sys/devices/system/cpu/cpu*/cpufreq/scaling_available_governors /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors:conservative ondemand userspace powersave performance schedutil /sys/devices/system/cpu/cpu10/cpufreq/scaling_available_governors:conservative ondemand userspace powersave performance schedutil /sys/devices/system/cpu/cpu11/cpufreq/scaling_available_governors:conservative ondemand userspace powersave performance schedutil /sys/devices/system/cpu/cpu12/cpufreq/scaling_available_governors:conservative ondemand userspace powersave performance schedutil /sys/devices/system/cpu/cpu13/cpufreq/scaling_available_governors:conservative ondemand userspace powersave performance schedutil /sys/devices/system/cpu/cpu14/cpufreq/scaling_available_governors:conservative ondemand userspace powersave performance schedutil /sys/devices/system/cpu/cpu15/cpufreq/scaling_available_governors:conservative ondemand userspace powersave performance schedutil /sys/devices/system/cpu/cpu16/cpufreq/scaling_available_governors:conservative ondemand userspace powersave performance schedutil /sys/devices/system/cpu/cpu17/cpufreq/scaling_available_governors:conservative ondemand userspace powersave performance schedutil /sys/devices/system/cpu/cpu18/cpufreq/scaling_available_governors:conservative ondemand userspace powersave performance schedutil /sys/devices/system/cpu/cpu19/cpufreq/scaling_available_governors:conservative ondemand userspace powersave performance schedutil /sys/devices/system/cpu/cpu1/cpufreq/scaling_available_governors:conservative ondemand userspace powersave performance schedutil /sys/devices/system/cpu/cpu20/cpufreq/scaling_available_governors:conservative ondemand userspace powersave performance schedutil /sys/devices/system/cpu/cpu21/cpufreq/scaling_available_governors:conservative ondemand userspace powersave performance schedutil /sys/devices/system/cpu/cpu22/cpufreq/scaling_available_governors:conservative ondemand userspace powersave performance schedutil /sys/devices/system/cpu/cpu23/cpufreq/scaling_available_governors:conservative ondemand userspace powersave performance schedutil /sys/devices/system/cpu/cpu24/cpufreq/scaling_available_governors:conservative ondemand userspace powersave performance schedutil /sys/devices/system/cpu/cpu25/cpufreq/scaling_available_governors:conservative ondemand userspace powersave performance schedutil /sys/devices/system/cpu/cpu26/cpufreq/scaling_available_governors:conservative ondemand userspace powersave performance schedutil /sys/devices/system/cpu/cpu27/cpufreq/scaling_available_governors:conservative ondemand userspace powersave performance schedutil /sys/devices/system/cpu/cpu28/cpufreq/scaling_available_governors:conservative ondemand userspace powersave performance schedutil /sys/devices/system/cpu/cpu29/cpufreq/scaling_available_governors:conservative ondemand userspace powersave performance schedutil /sys/devices/system/cpu/cpu2/cpufreq/scaling_available_governors:conservative ondemand userspace powersave performance schedutil /sys/devices/system/cpu/cpu30/cpufreq/scaling_available_governors:conservative ondemand userspace powersave performance schedutil /sys/devices/system/cpu/cpu31/cpufreq/scaling_available_governors:conservative ondemand userspace powersave performance schedutil /sys/devices/system/cpu/cpu32/cpufreq/scaling_available_governors:conservative ondemand userspace powersave performance schedutil /sys/devices/system/cpu/cpu33/cpufreq/scaling_available_governors:conservative ondemand userspace powersave performance schedutil /sys/devices/system/cpu/cpu34/cpufreq/scaling_available_governors:conservative ondemand userspace powersave performance schedutil /sys/devices/system/cpu/cpu35/cpufreq/scaling_available_governors:conservative ondemand userspace powersave performance schedutil /sys/devices/system/cpu/cpu3/cpufreq/scaling_available_governors:conservative ondemand userspace powersave performance schedutil /sys/devices/system/cpu/cpu4/cpufreq/scaling_available_governors:conservative ondemand userspace powersave performance schedutil /sys/devices/system/cpu/cpu5/cpufreq/scaling_available_governors:conservative ondemand userspace powersave performance schedutil /sys/devices/system/cpu/cpu6/cpufreq/scaling_available_governors:conservative ondemand userspace powersave performance schedutil /sys/devices/system/cpu/cpu7/cpufreq/scaling_available_governors:conservative ondemand userspace powersave performance schedutil /sys/devices/system/cpu/cpu8/cpufreq/scaling_available_governors:conservative ondemand userspace powersave performance schedutil /sys/devices/system/cpu/cpu9/cpufreq/scaling_available_governors:conservative ondemand userspace powersave performance schedutil |
此时再查看scaling_driver:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# grep . /sys/devices/system/cpu/cpu*/cpufreq/scaling_driver /sys/devices/system/cpu/cpu0/cpufreq/scaling_driver:intel_cpufreq /sys/devices/system/cpu/cpu10/cpufreq/scaling_driver:intel_cpufreq /sys/devices/system/cpu/cpu11/cpufreq/scaling_driver:intel_cpufreq /sys/devices/system/cpu/cpu12/cpufreq/scaling_driver:intel_cpufreq /sys/devices/system/cpu/cpu13/cpufreq/scaling_driver:intel_cpufreq /sys/devices/system/cpu/cpu14/cpufreq/scaling_driver:intel_cpufreq /sys/devices/system/cpu/cpu15/cpufreq/scaling_driver:intel_cpufreq /sys/devices/system/cpu/cpu16/cpufreq/scaling_driver:intel_cpufreq /sys/devices/system/cpu/cpu17/cpufreq/scaling_driver:intel_cpufreq /sys/devices/system/cpu/cpu18/cpufreq/scaling_driver:intel_cpufreq /sys/devices/system/cpu/cpu19/cpufreq/scaling_driver:intel_cpufreq /sys/devices/system/cpu/cpu1/cpufreq/scaling_driver:intel_cpufreq /sys/devices/system/cpu/cpu20/cpufreq/scaling_driver:intel_cpufreq /sys/devices/system/cpu/cpu21/cpufreq/scaling_driver:intel_cpufreq /sys/devices/system/cpu/cpu22/cpufreq/scaling_driver:intel_cpufreq /sys/devices/system/cpu/cpu23/cpufreq/scaling_driver:intel_cpufreq /sys/devices/system/cpu/cpu24/cpufreq/scaling_driver:intel_cpufreq /sys/devices/system/cpu/cpu25/cpufreq/scaling_driver:intel_cpufreq /sys/devices/system/cpu/cpu26/cpufreq/scaling_driver:intel_cpufreq /sys/devices/system/cpu/cpu27/cpufreq/scaling_driver:intel_cpufreq /sys/devices/system/cpu/cpu28/cpufreq/scaling_driver:intel_cpufreq /sys/devices/system/cpu/cpu29/cpufreq/scaling_driver:intel_cpufreq /sys/devices/system/cpu/cpu2/cpufreq/scaling_driver:intel_cpufreq /sys/devices/system/cpu/cpu30/cpufreq/scaling_driver:intel_cpufreq /sys/devices/system/cpu/cpu31/cpufreq/scaling_driver:intel_cpufreq /sys/devices/system/cpu/cpu32/cpufreq/scaling_driver:intel_cpufreq /sys/devices/system/cpu/cpu33/cpufreq/scaling_driver:intel_cpufreq /sys/devices/system/cpu/cpu34/cpufreq/scaling_driver:intel_cpufreq /sys/devices/system/cpu/cpu35/cpufreq/scaling_driver:intel_cpufreq /sys/devices/system/cpu/cpu3/cpufreq/scaling_driver:intel_cpufreq /sys/devices/system/cpu/cpu4/cpufreq/scaling_driver:intel_cpufreq /sys/devices/system/cpu/cpu5/cpufreq/scaling_driver:intel_cpufreq /sys/devices/system/cpu/cpu6/cpufreq/scaling_driver:intel_cpufreq /sys/devices/system/cpu/cpu7/cpufreq/scaling_driver:intel_cpufreq /sys/devices/system/cpu/cpu8/cpufreq/scaling_driver:intel_cpufreq /sys/devices/system/cpu/cpu9/cpufreq/scaling_driver:intel_cpufreq |
再次使用cpufreq-set就不会报错了:
1 2 |
# cpufreq-set -g ondemand # sudo bash -c 'for ((i=0;i<$(nproc);i++)); do cpufreq-set -c $i -g ondemand; done' |
另外,参考文档2给出了有关HWP(HardWare Pstate control)的一些说法。
根据这个线索可以搜索到https://www.kernel.org/doc/html/v4.19/admin-guide/pm/intel_pstate.html,其中有详细HWP的主动及被动模式。值得注意的是,其中明确提到,HWP active模式下的powersave和performance跟generic scaling governor中同名的含义是不同的:
They are not generic scaling governors, but their names are the same as the names of some of those governors. Moreover, confusingly enough, they generally do not work in the same way as the generic governors they share the names with. For example, the
powersave
P-state selection algorithm provided byintel_pstate
is not a counterpart of the genericpowersave
governor (roughly, it corresponds to theschedutil
andondemand
governors).
参考文档:
1、https://askubuntu.com/questions/1322492/how-to-set-as-default-performance-mode-on-ubuntu-20-04-instead-of-powersave
2、https://askubuntu.com/questions/1236947/how-to-add-power-governors
转载时请保留出处,违法转载追究到底:进城务工人员小梅 » Ubuntu 20.04下Intel CPU电源管理策略只有powersave和performance的问题