安装 cpupower 软件
sudoaptinstalllinux-tools-common linux-tools-$(name-r)设置linux系统cpu固定频率,报如下错误:
$sudocpufreq-set-c0-f1000MHz Error setting new values. Common errors: - Do you have proper administration rights?(super-user?)- Is the governor you requested available and modprobed? - Trying tosetan invalid policy? - Trying toseta specific frequency, but userspace governor is not available,forexample because of hardwarewhichcannot besetto a specific frequency or because the userspace governor isn't loaded?从Ubuntu使用intel某些cpu的pc上默认使用intel_pstate cpufreq driver。后果就是只有performance和powersave两个governor可用。可通过下面命令确认:
$ cpufreq-info cpufrequtils 008: cpufreq-info(C)Dominik Brodowski2004-2009 Report errors and bugs to cpufreq@vger.kernel.org, please. analyzing CPU0: driver: intel_pstate CPUswhichrun at the same hardware frequency:0CPUswhichneed to have their frequency coordinated by software:0maximum transition latency:4294.55ms. hardware limits:800MHz -3.90GHZ available cpufreq governors: performance, powersave current policy: frequency should be within800MHz and3.90GHz. The governor"powersave"may decidewhichspeed to use within this range. current CPU frequency is800MHz. analyzing CPU1: driver: intel_pstate CPUswhichrun at the same hardware frequency:1CPUswhichneed to have their frequency coordinated by software:1maximum transition latency:4294.55ms. hardware limits:800MHz -3.90GHZ available cpufreq governors: performance, powersave current policy: frequency should be within800MHz and3.90GHz. The governor"powersave"may decidewhichspeed to use within this range. current CPU frequency is802MHz.可以看到
driver: intel_pstate
available cpufreq governors: performance, powersave
禁用intel_pstate:
修改 /etc/default/grub中GRUB_CMDLINE_LINUX_DEFAULT内容
原始内容: GRUB_CMDLINE_LINUX_DEFAULT=“quietsplash”
更改后的内容:GRUB_CMDLINE_LINUX_DEFAULT=“quietsplash intel_pstate=disable”
更新grub :sudo update-grub
重启机器
设置cpu固定频率
sudo cpufreq-set -g userspace
sudo cpupower frequency-set -f 2.0GHz
查看cpu频率
cat /proc/cpuinfo | grep MH
设置CPU Performance模式
# cpupower设置performancecpupower frequency-set-gperformance# 查看当前的调节器cat/sys/devices/system/cpu/cpu*/cpufreq/scaling_governor performance