【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(调频)可以调节的最低频率;
相关推荐
看到代码头都是大的6 小时前
Windows环境下绿色版nginx 1.30使用
运维·nginx
IT研究所6 小时前
AI 时代下的知识管理:从 Claude 的“复盘”能力看生成式 AI价值
大数据·运维·数据库·人工智能·科技·低代码·自然语言处理
仙柒4156 小时前
管理网络安全
linux·运维·服务器
isyangli_blog6 小时前
静态网站部署方案
服务器
云边云科技_云网融合6 小时前
企业出海的 “数字丝绸之路“:SD-WAN 如何重构全球网络竞争力
大数据·运维·网络·人工智能
JZC_xiaozhong6 小时前
2026年深圳企业如何统一管理ERP、MES、OA权限?身份识别与访问管理高效方案
大数据·运维·自动化·企业数据安全·数据集成与应用集成·权限治理·多系统权限管理
福尔摩斯·柯南7 小时前
Ubuntu 14.04/16.04/18.04/20.04/22.04/24.04/26.04全系列LTS长期支持版镜像IOS分享
linux·运维·ubuntu
xiaoming00187 小时前
JAVA项目打包部署运维全流程(多服务、批量)
java·linux·运维
189228048617 小时前
NV243美光MT29F32T08GWLBHD6-24QJES:B
大数据·服务器·人工智能·科技·缓存
浪客灿心8 小时前
Linux五种IO模型与非阻塞IO
linux·网络