admin管理员组

文章数量:1658732

修改cpu频率

一、安装cpufreq相关命令

sudo apt install cpufrequtils

二、查看cpufreq-info,可以看到available cpufreq governors: performance, powersave,只有两个。

$ cpufreq-info
cpufrequtils 008: cpufreq-info (C) Dominik Brodowski 2004-2009
Report errors and bugs to cpufreq@vger.kernel, please.
analyzing CPU 0:
  driver: intel_pstate
  CPUs which run at the same hardware frequency: 0
  CPUs which need to have their frequency coordinated by software: 0
  maximum transition latency: 4294.55 ms.
  hardware limits: 1.20 GHz - 3.40 GHz
  available cpufreq governors: performance, powersave
  current policy: frequency should be within 1.20 GHz and 3.40 GHz.
                  The governor "powersave" may decide which speed to use
                  within this range.
  current CPU frequency is 1.20 GHz.
analyzing CPU 1:
  driver: intel_pstate
  CPUs which run at the same hardware frequency: 1
  CPUs which need to have their frequency coordinated by software: 1
  maximum transition latency: 4294.55 ms.
  hardware limits: 1.20 GHz - 3.40 GHz
  available cpufreq governors: performance, powersave
  current policy: frequency should be within 1.20 GHz and 3.40 GHz.
                  The governor "powersave" may decide which speed to use
                  within this range.
  current CPU frequency is 1.20 GHz.

三、设置频率,出现一下提示

$ sudo cpufreq-set -c 39 -f 2.4G
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. 在/etc/default/grub中加入 GRUB_CMDLINE_LINUX_DEFAULT=“intel_pstate=disable”

  2. 命令行输入:sudo update-grub2

  3. 重启:sudo reboot

  4. 再次查看cpufreq-info,可以看到有更多的governors: available cpufreq governors: conservative, ondemand, userspace, powersave, performance, schedutil

$ cpufreq-info
cpufrequtils 008: cpufreq-info (C) Dominik Brodowski 2004-2009
Report errors and bugs to cpufreq@vger.kernel, please.
analyzing CPU 0:
  driver: acpi-cpufreq
  CPUs which run at the same hardware frequency: 0
  CPUs which need to have their frequency coordinated by software: 0
  maximum transition latency: 10.0 us.
  hardware limits: 1.20 GHz - 2.40 GHz
  available frequency steps: 2.40 GHz, 2.30 GHz, 2.20 GHz, 2.10 GHz, 2.00 GHz, 1.90 GHz, 1.80 GHz, 1.70 GHz, 1.60 GHz, 1.50 GHz, 1.40 GHz, 1.30 GHz, 1.20 GHz
  available cpufreq governors: conservative, ondemand, userspace, powersave, performance, schedutil
  current policy: frequency should be within 1.20 GHz and 2.40 GHz.
                  The governor "ondemand" may decide which speed to use
                  within this range.
  current CPU frequency is 1.20 GHz.
  cpufreq stats: 2.40 GHz:11.66%, 2.30 GHz:0.23%, 2.20 GHz:0.07%, 2.10 GHz:0.13%, 2.00 GHz:2.22%, 1.90 GHz:1.31%, 1.80 GHz:0.30%, 1.70 GHz:0.46%, 1.60 GHz:0.75%, 1.50 GHz:0.39%, 1.40 GHz:0.83%, 1.30 GHz:1.18%, 1.20 GHz:80.47%  (244)

再次设置

# cpufreq-set -c 0 -f 2.4G
# cpufreq-info -c 0
cpufrequtils 008: cpufreq-info (C) Dominik Brodowski 2004-2009
Report errors and bugs to cpufreq@vger.kernel, please.
analyzing CPU 0:
  driver: acpi-cpufreq
  CPUs which run at the same hardware frequency: 0
  CPUs which need to have their frequency coordinated by software: 0
  maximum transition latency: 10.0 us.
  hardware limits: 1.20 GHz - 2.40 GHz
  available frequency steps: 2.40 GHz, 2.30 GHz, 2.20 GHz, 2.10 GHz, 2.00 GHz, 1.90 GHz, 1.80 GHz, 1.70 GHz, 1.60 GHz, 1.50 GHz, 1.40 GHz, 1.30 GHz, 1.20 GHz
  available cpufreq governors: conservative, ondemand, userspace, powersave, performance, schedutil
  current policy: frequency should be within 1.20 GHz and 2.40 GHz.
                  The governor "userspace" may decide which speed to use
                  within this range.
  current CPU frequency is 2.40 GHz (asserted by call to hardware)
  cpufreq stats: 2.40 GHz:18.38%, 2.30 GHz:0.09%, 2.20 GHz:0.03%, 2.10 GHz:0.06%, 2.00 GHz:0.84%, 1.90 GHz:0.50%, 1.80 GHz:0.12%, 1.70 GHz:0.24%, 1.60 GHz:0.29%, 1.50 GHz:0.19%, 1.40 GHz:1.02%, 1.30 GHz:1.65%, 1.20 GHz:76.60%  (407)
root@supermicro:/home/bitmain#

performance 运行于最大频率

powersave 运行于最小频率

userspace 运行于用户指定的频率

ondemand 按需快速动态调整CPU频率, 一有cpu计算量的任务,就会立即达到最大频率运行,空闲时间增加就降低频率

conservative 按需快速动态调整CPU频率, 比 ondemand 的调整更保守

schedutil 基于调度程序调整 CPU 频率

可以用-g参数来设定,命令如:sudo cpufreq-set -g performance

四、关闭睿频




本文标签: 频率CPU