【Linux】CPU当前频率及调整CPU频率操作

CPU的governor(调频)策略

governor(调频)策略,linux内核一共有5种调频策略:

performance-最高性能,直接使用最高频率,不考虑耗电;

interactive-一开始直接使用最高频率,然后根据CPU负载慢慢降低;

powersave-省电模式,通常以最低频率运行,性能会受影响,一般不会使用;

userspace-可以在用户空间手动调节频率;

ondemand-定时检查负载,然后根据负载来调节频率。负载低的时候降低CPU频率,否则相反。

物理硬件配置
配置项 WELTEST
CPU调频策略 performance
CPU型号 Intel® Xeon® Gold 6248 CPU @ 2.50GHz
CPU刷新频率范围 1000 MHz - 3.90 GHz
内存 256G
网卡 10000Mb/s

4、调整前WELTEST最大刷新频率为'3.9Ghz'

bash 复制代码
[root@weltest ~]# cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_max_freq |uniq
3900000

5、调整weltest最大刷新频率为'2.9Ghz'

bash 复制代码
[root@weltest ~]# cpupower frequency-set -u 2900000

查看调整后最大刷新频率:

复制代码
cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_max_freq |uniq
CPU型号查询命令
bash 复制代码
[root@weltest etc]$ lscpu
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                160
On-line CPU(s) list:   0-159
Thread(s) per core:    2
Core(s) per socket:    20
座:                 4
NUMA 节点:         4
厂商 ID:           GenuineIntel
CPU 系列:          6
型号:              85
型号名称:        Intel(R) Xeon(R) Gold 6248 CPU @ 2.50GHz
步进:              7
CPU MHz:             1530.151
CPU max MHz:           3900.0000
CPU min MHz:           1000.0000
BogoMIPS:            5000.00
虚拟化:           VT-x
L1d 缓存:          32K
L1i 缓存:          32K
L2 缓存:           1024K
L3 缓存:           28160K
NUMA 节点0 CPU:    0-19,80-99
NUMA 节点1 CPU:    20-39,100-119
NUMA 节点2 CPU:    40-59,120-139
NUMA 节点3 CPU:    60-79,140-159
Flags:                 fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch epb cat_l3 cdp_l3 intel_ppin intel_pt ssbd mba ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm cqm mpx rdt_a avx512f avx512dq rdseed adx smap clflushopt clwb avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts hwp hwp_act_window hwp_pkg_req pku ospke avx512_vnni spec_ctrl intel_stibp flush_l1d arch_capabilities

或者使用 cpupower frequency-info

bash 复制代码
[root@weltest etc]$ cpupower frequency-info
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:  Cannot determine or is not supported.
  hardware limits: 1000 MHz - 3.90 GHz
  available cpufreq governors: performance powersave
  current policy: frequency should be within 1000 MHz and 3.90 GHz.
                  The governor "performance" may decide which speed to use
                  within this range.
  current CPU frequency: Unable to call hardware
  current CPU frequency: 1.37 GHz (asserted by call to kernel)
  boost state support:
    Supported: yes
    Active: yes

[root@weltest etc]$ 
内存信息
bash 复制代码
[root@weltest ~]# free -g
              total        used        free      shared  buff/cache   available
Mem:            251          80          91           3          79         166
Swap:            63           4          59
CPU调频策略查看命令
bash 复制代码
cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor | uniq
某个CPU频率详细信息
bash 复制代码
cd /sys/devices/system/cpu/cpu01/cpufreq

目录下文件简述:

复制代码
cpuinfo_cur_freq:当前CPU工作频率,从CPU寄存器读取;
cpuinfo_max_freq:处理器能运行的最高工作频率(单位:KHz);
cpuinfo_min_freq:处理器能运行的最低工作频率(单位:KHz);
cpuinfo_transition_latency:处理器切换频率所需的事件(单位:ns)

scaling_available_governors:当前内核中支持的所有governor(调频)类型;
scaling_cur_freq:保存着cpufreq模块缓存的当前CPU频率,不会对CPU硬件寄存器进行检查;
scaling_driver:该文件保存当前CPU所调用的调频驱动;
scaling_governor:governor(调频)策略,linux内核一共有5种调频策略:Performance-最高性能,直接使用最高频率,不考虑耗电;Interactive-一开始直接使用最高频率,然后根据CPU负载慢慢降低;Powersave-省电模式,通常以最低频率运行,性能会受影响,一般不会使用;Userspace-可以在用户空间手动调节频率;Ondemand-定时检查负载,然后根据负载来调节频率。负载低的时候降低CPU频率,否则相反。
scaling_max_freq:governor(调频)可以调节的最高频率;
scaling_min_freq:governor(调频)可以调节的最低频率;
相关推荐
EricFRQ1 小时前
devops自动化容器化部署
运维·自动化·devops
白云~️2 小时前
uniappx 打包配置32位64位x86安装包
运维·服务器·github
在河之洲木水2 小时前
现代多核调度器的本质 调度三重奏
linux·服务器·系统架构
文牧之3 小时前
PostgreSQL的扩展 pgcrypto
运维·数据库·postgresql
程序员JerrySUN3 小时前
驱动开发硬核特训 · Day 22(下篇): # 深入理解 Power-domain 框架:概念、功能与完整代码剖析
linux·开发语言·驱动开发·嵌入式硬件
白总Server3 小时前
多智能体系统的中间件架构
linux·运维·服务器·中间件·ribbon·架构·github
未来会更好yes3 小时前
Centos 7.6安装redis-6.2.6
linux·redis·centos
二猛子3 小时前
Linux(Centos版本)中安装Docker
linux·docker·centos
浪裡遊5 小时前
跨域问题(Cross-Origin Problem)
linux·前端·vue.js·后端·https·sprint
Johny_Zhao5 小时前
OpenStack 全套搭建部署指南(基于 Kolla-Ansible)
linux·python·信息安全·云计算·openstack·shell·yum源·系统运维