cpupower调整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@CENTOS ~]# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
conservative userspace powersave ondemand performance
[root@CENTOS ~]#
查看cpu0可用的策略:cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors

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

[root@CENTOS ~]# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
conservative
[root@CENTOS ~]#
查看cpu0当前的策略:cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

4、查看当前CPU频率

[root@CENTOS ~]# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq
1000000
[root@CENTOS ~]#

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

[root@CENTOS ~]# 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: 1000 MHz - 1.90 GHz
  available frequency steps:  1.90 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, 1.10 GHz, 1000 MHz
  available cpufreq governors: conservative userspace powersave ondemand performance
  current policy: frequency should be within 1000 MHz and 1.90 GHz.
                  The governor "conservative" may decide which speed to use
                  within this range.
  current CPU frequency: 1000 MHz (asserted by call to hardware)
  boost state support:
    Supported: yes
    Active: yes

6、设置所有CPU的模式

设置所有CPU为性能模式
[root@CENTOS57 ~]# 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
Setting cpu: 7
Setting cpu: 8
Setting cpu: 9
Setting cpu: 10
Setting cpu: 11
Setting cpu: 12
Setting cpu: 13
Setting cpu: 14
Setting cpu: 15
cpupower -c all frequency-set -g powersave
cpupower -c all frequency-set -g "conservative"

7、查看某个CPU的信息

[root@CENTOS57 ~]# 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: 1000 MHz - 1.90 GHz
  available frequency steps:  1.90 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, 1.10 GHz, 1000 MHz
  available cpufreq governors: conservative userspace powersave ondemand performance
  current policy: frequency should be within 1000 MHz and 1.90 GHz.
                  The governor "performance" may decide which speed to use
                  within this range.
  current CPU frequency: 1.90 GHz (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@CENTOS57 ~]# cat /proc/cpuinfo | grep "cpu MHz*"
cpu MHz         : 1901.000
cpu MHz         : 1901.000
cpu MHz         : 1901.000
cpu MHz         : 1901.000
cpu MHz         : 1901.000
cpu MHz         : 1901.000
cpu MHz         : 1901.000
cpu MHz         : 1901.000
cpu MHz         : 1901.000
cpu MHz         : 1901.000
cpu MHz         : 1901.000
cpu MHz         : 1901.000
cpu MHz         : 1901.000
cpu MHz         : 1901.000
cpu MHz         : 1901.000
cpu MHz         : 1901.000

参考引用:https://baijiahao.baidu.com/s?id=1644209827783392362&wfr=spider&for=pc

posted on 2020-11-09 14:33  裸睡的猪  阅读(9939)  评论(0编辑  收藏  举报