使用cpupower
,我可以设置任意最小和最大频率。然而,CPU 会将这些值舍入到它可以执行的下一个频率范围(我认为这是因为频率倍增器)。
我还没有找到一种方法来获取所有可用频率的列表,无论是通过 cpupower 还是任何其他工具或文件。拥有这些信息真是太棒了。
我发现的唯一的事情是cpupower frequency-info
应该有一行包含此类信息(根据谷歌),但它在我的系统上丢失了。这是我的输出:
~ 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: 800 MHz - 3.80 GHz
available cpufreq governors: performance powersave
current policy: frequency should be within 800 MHz and 2.80 GHz.
The governor "powersave" may decide which speed to use
within this range.
current CPU frequency: Unable to call hardware
current CPU frequency: 2.80 GHz (asserted by call to kernel)
boost state support:
Supported: yes
Active: yes
这是我的 cpuinfo:
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 158
model name : Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
stepping : 9
microcode : 0x84
cpu MHz : 2791.480
cache size : 6144 KB
physical id : 0
siblings : 8
core id : 0
cpu cores : 4
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 22
wp : yes
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 cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single pti tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves ibpb ibrs stibp dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp
bugs : cpu_meltdown spectre_v1 spectre_v2
bogomips : 5618.00
clflush size : 64
cache_alignment : 64
address sizes : 39 bits physical, 48 bits virtual
power management:
答案1
我四处搜寻,正如评论所说,似乎不再维护频率表。
假设频率是线性缩放的,您可以通过查看目录来近似它们。
为了帮助输入,创建此别名:
alias cpuinfo="paste <(ls *) <(cat *) | column -s $'\t' -t"
首先找出频率步数
$ cd /sys/devices/system/cpu/intel_pstate
$ cpuinfo
max_perf_pct 100
min_perf_pct 22
no_turbo 0
num_pstates 28
status active
turbo_pct 33
我们有 28 个频率步长,由 确定num_pstates
。
现在看看最小和最大频率 MHz,它可以根据 Turbo Boost 启用/禁用状态而变化:
cd /sys/devices/system/cpu/cpu0/cpufreq
$ cpuinfo
affected_cpus 0
cpuinfo_max_freq 3500000
cpuinfo_min_freq 800000
cpuinfo_transition_latency 4294967295
energy_performance_available_preferences default performance balance_performance balance_power power
energy_performance_preference balance_performance
related_cpus 0
scaling_available_governors performance powersave
scaling_cur_freq 837225
scaling_driver intel_pstate
scaling_governor powersave
scaling_max_freq 3500000
scaling_min_freq 800000
scaling_setspeed <unsupported>
我稍后可能会编写一个脚本来自动显示频率,但要手动执行此操作:
- 步速=(
max
-min
)/steps
。例如(3500-800)/28=96.428 - 重复28次:速率=上次速率+步进速率。例如
800.00
,,,,,, ...896.42
992.856
1089.284
1185.712
1282.14
列出频率的脚本
您可以将此函数复制并粘贴到您的终端中:
ApproximateFrequencies () {
NumSteps=$(cat /sys/devices/system/cpu/intel_pstate/num_pstates)
MinFreq=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq)
MaxFreq=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq)
LastFreq=$MinFreq
StepRate=$((( $MaxFreq - $MinFreq ) / $NumSteps))
for ((n=0;n<=$NumSteps;n++)); do
echo $LastFreq
LastFreq=$(( $LastFreq + $StepRate))
done
}
然后使用以下命令运行该函数ApproximateFrequencies
:
800000
896428
992856
. . .
3403556
3499984
column
如果安装了它,最好还是通过命令进行管道传输:
$ ApproximateFrequencies | column
800000 1089284 1378568 1667852 1957136 2246420 2535704 2824988 3114272 3403556
896428 1185712 1474996 1764280 2053564 2342848 2632132 2921416 3210700 3499984
992856 1282140 1571424 1860708 2149992 2439276 2728560 3017844 3307128
答案2
我可以/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies
检查
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies
这不仅限于英特尔。我不知道它们是否是圆形的。
内核版本:5.4.0-74
相关文档https://www.kernel.org/doc/Documentation/cpu-freq/user-guide.txt