在这里,一丝一缕织就的记忆,只属于我自己。

PVE下调整CPU运行策略

1、调节策略

performance:将CPU频率固定工作在其支持的最高运行频率上,不动态调节,可以获取到最大的性能。

powersave: 将 CPU 频率设置为最低的所谓 “省电” 模式,CPU 会固定工作在其支持的最低运行频率上。

因此这两种 governors 都属于静态 governor,即在使用它们时 CPU 的运行频率不会根据系统运行时负载的变化动态作出调整。

这两种 governors 对应的是两种极端的应用场景,使用 performance governor 是对系统高性能的最大追求,而使用 powersave governor 则是对系统低功耗的最大追求。

userspace:最早的 cpufreq 子系统通过 userspace governor 为用户提供了这种灵活性。

系统将变频策略的决策权交给了用户态应用程序,并提供了相应的接口供用户态应用程序调节 CPU 运行频率使用。

ondemand:按需快速动态调整 CPU 频率, 一有 cpu 计算量的任务,就会立即达到最大频率运行,等执行完毕就立即回到最低频率;

ondemand:userspace 是内核态的检测,用户态调整,效率低。

conservative: 与 ondemand 不同,平滑地调整 CPU 频率,频率的升降是渐变式的, 会自动在频率上下限调整,和 ondemand 的区别在于它会按需分配频率,而不是一味追求最高频率;

2、查看当前cpu可用的策略

root@G8505:~# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
conservative ondemand userspace powersave performance schedutil

3、查看当前cpu生效的策略

root@G8505:~# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
conservative

4、查看当前CPU频率

root@G8505:~# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq
1042159

5、查看当前所有CPU的信息

root@G8505:~# cpupower -c all frequency-info
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: 400 MHz - 2.50 GHz
  available frequency steps:  2.50 GHz, 2.50 GHz, 2.30 GHz, 2.20 GHz, 2.00 GHz, 1.90 GHz, 1.70 GHz, 1.60 GHz, 1.40 GHz, 1.20 GHz, 1.10 GHz, 1000 MHz, 800 MHz, 700 MHz, 500 MHz, 400 MHz
  available cpufreq governors: conservative ondemand userspace powersave performance schedutil
  current policy: frequency should be within 400 MHz and 2.50 GHz.
                  The governor "conservative" may decide which speed to use
                  within this range.
  current CPU frequency: 400 MHz (asserted by call to hardware)
  boost state support:
    Supported: yes
    Active: yes

6、设置所有CPU的模式

#设置所有CPU为性能模式
cpupower -c all frequency-set -g performance
Setting cpu: 0
Setting cpu: 1
Setting cpu: 2
Setting cpu: 3
Setting cpu: 4
Setting cpu: 5
Setting cpu: 6
cpupower -c all frequency-set -g powersave
cpupower -c all frequency-set -g "conservative"

7、查看某个CPU的信息

root@G8505:~# cpupower -c 1 frequency-info
analyzing CPU 1:
  driver: acpi-cpufreq
  CPUs which run at the same hardware frequency: 1
  CPUs which need to have their frequency coordinated by software: 1
  maximum transition latency: 10.0 us
  hardware limits: 400 MHz - 2.50 GHz
  available frequency steps:  2.50 GHz, 2.50 GHz, 2.30 GHz, 2.20 GHz, 2.00 GHz, 1.90 GHz, 1.70 GHz, 1.60 GHz, 1.40 GHz, 1.20 GHz, 1.10 GHz, 1000 MHz, 800 MHz, 700 MHz, 500 MHz, 400 MHz
  available cpufreq governors: conservative ondemand userspace powersave performance schedutil
  current policy: frequency should be within 400 MHz and 2.50 GHz.
                  The governor "conservative" may decide which speed to use
                  within this range.
  current CPU frequency: 400 MHz (asserted by call to hardware)
  boost state support:
    Supported: yes
    Active: yes
cpupower -c 0 frequency-info        #查看CPU0的信息
cpupower -c 1 frequency-info        #查看CPU1的信息
cpupower -c 2 frequency-info        #查看CPU2的信息

8、查看CPU的频率

root@G8505:~# cat /proc/cpuinfo | grep "cpu MHz*"
cpu MHz         : 1085.001
cpu MHz         : 1056.808
cpu MHz         : 1045.716
cpu MHz         : 1025.742
cpu MHz         : 1107.442
cpu MHz         : 1079.051
赞(0)
未经允许不得转载:一把剪刀 » PVE下调整CPU运行策略

评论 抢沙发