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(调频)可以调节的最低频率;