【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(调频)可以调节的最低频率;
相关推荐
IMPYLH6 分钟前
Linux 运维基础:从入门到实战的完整指南
linux·运维·php
前端 贾公子13 分钟前
LangGraph == 图的状态(State)管理 (下)
运维·服务器·数据库
Lsetea14 分钟前
curl走HTTPS代理报SSL证书错误:proxy-cacert与cacert双层信任排查
linux·https·ssl证书·curl·代理服务器
星恒随风17 分钟前
Linux进程间通信(二):深入理解System V共享内存、消息队列、信号量与内核IPC资源管理
linux·运维·服务器·笔记·学习·状态模式
yangmu320326 分钟前
PLC 设备介绍:工业自动化的“控制大脑”
运维·自动化
IMPYLH31 分钟前
Linux 文件检索:find、locate、grep 与 which 实战指南
linux·运维·服务器
腾讯蓝鲸智云38 分钟前
【运维自动化-监控平台】如何配置进程监控之基于进程名规则匹配
运维·自动化·云计算·sass·paas
优化Henry41 分钟前
LTE基站传输割接后S1连接失败排查实录
运维·网络·笔记·学习·信息与通信
西索斯coding43 分钟前
Claude Code 工具调用返回空怎么办?claude-opus-5.5 的 input_schema 校验踩坑记录与修复方案
服务器·前端·javascript·ai
流烟默1 小时前
ClickHouse Part 机制与写入优化实践指南
大数据·运维·clickhouse