![使用 CPUFreq Gnome 扩展的固定频率问题](https://linux22.com/image/1174585/%E4%BD%BF%E7%94%A8%20CPUFreq%20Gnome%20%E6%89%A9%E5%B1%95%E7%9A%84%E5%9B%BA%E5%AE%9A%E9%A2%91%E7%8E%87%E9%97%AE%E9%A2%98.png)
答案1
如果负载足够低,即使将最小值和最大值都设置为最高级别,处理器也会自行降低 CPU 频率。您不应该注意到性能方面的问题。但是,如果这真的很重要,我知道将 CPU 频率锁定在最大值的唯一方法是禁用每个深度大于 0 的空闲状态,但代价是巨大的功率。
因此,对于正常的默认设置:
doug@s18:~/c$ grep . /sys/devices/system/cpu/cpu*/cpufreq/scaling_driver
/sys/devices/system/cpu/cpu0/cpufreq/scaling_driver:intel_pstate
/sys/devices/system/cpu/cpu1/cpufreq/scaling_driver:intel_pstate
/sys/devices/system/cpu/cpu2/cpufreq/scaling_driver:intel_pstate
/sys/devices/system/cpu/cpu3/cpufreq/scaling_driver:intel_pstate
/sys/devices/system/cpu/cpu4/cpufreq/scaling_driver:intel_pstate
/sys/devices/system/cpu/cpu5/cpufreq/scaling_driver:intel_pstate
doug@s18:~/c$ grep . /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor:powersave
/sys/devices/system/cpu/cpu1/cpufreq/scaling_governor:powersave
/sys/devices/system/cpu/cpu2/cpufreq/scaling_governor:powersave
/sys/devices/system/cpu/cpu3/cpufreq/scaling_governor:powersave
/sys/devices/system/cpu/cpu4/cpufreq/scaling_governor:powersave
/sys/devices/system/cpu/cpu5/cpufreq/scaling_governor:powersave
对于轻负载,你会得到类似这样的结果:
doug@s18:~/c$ grep . /sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq
/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq:800229
/sys/devices/system/cpu/cpu1/cpufreq/scaling_cur_freq:800287
/sys/devices/system/cpu/cpu2/cpufreq/scaling_cur_freq:800174
/sys/devices/system/cpu/cpu3/cpufreq/scaling_cur_freq:800286
/sys/devices/system/cpu/cpu4/cpufreq/scaling_cur_freq:800049
/sys/devices/system/cpu/cpu5/cpufreq/scaling_cur_freq:800188
现在,按照您所做的进行更改:
doug@s18:~/c$ echo performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
performance
doug@s18:~/c$ grep . /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor:performance
/sys/devices/system/cpu/cpu1/cpufreq/scaling_governor:performance
/sys/devices/system/cpu/cpu2/cpufreq/scaling_governor:performance
/sys/devices/system/cpu/cpu3/cpufreq/scaling_governor:performance
/sys/devices/system/cpu/cpu4/cpufreq/scaling_governor:performance
/sys/devices/system/cpu/cpu5/cpufreq/scaling_governor:performance
doug@s18:~/c$ grep . /sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq
/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq:3987126
/sys/devices/system/cpu/cpu1/cpufreq/scaling_cur_freq:4600628
/sys/devices/system/cpu/cpu2/cpufreq/scaling_cur_freq:2559618
/sys/devices/system/cpu/cpu3/cpufreq/scaling_cur_freq:4600104
/sys/devices/system/cpu/cpu4/cpufreq/scaling_cur_freq:4601383
/sys/devices/system/cpu/cpu5/cpufreq/scaling_cur_freq:4600459
doug@s18:~/c$ echo 1 | sudo tee /sys/devices/system/cpu/intel_pstate/no_turbo
1
doug@s18:~/c$ grep . /sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq
/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq:3700405
/sys/devices/system/cpu/cpu1/cpufreq/scaling_cur_freq:3700291
/sys/devices/system/cpu/cpu2/cpufreq/scaling_cur_freq:3700381
/sys/devices/system/cpu/cpu3/cpufreq/scaling_cur_freq:3700612
/sys/devices/system/cpu/cpu4/cpufreq/scaling_cur_freq:3701802
/sys/devices/system/cpu/cpu5/cpufreq/scaling_cur_freq:3700702
事实上,令人惊讶地稳定。而且功率仍然很低:
doug@s18:~/c$ sudo ~/turbostat --Summary --quiet --show Busy%,Bzy_MHz,PkgTmp,PkgWatt,GFXWatt,IRQ --interval 6
Busy% Bzy_MHz IRQ PkgTmp PkgWatt GFXWatt
0.01 3689 196 30 1.91 0.00
0.01 3700 90 30 1.90 0.00
0.01 3667 142 30 1.91 0.00
0.01 3701 93 30 1.91 0.00
0.01 3620 119 30 1.89 0.00
0.01 3648 118 30 1.88 0.00
0.01 3603 147 30 1.86 0.00
0.00 3701 85 30 1.77 0.00
0.01 3700 102 30 1.84 0.00
但是,如果您希望它在 3.7 GHz 时更加稳定,则请禁用深度空闲状态,这样处理器就不会进入空闲状态(空闲状态 0 或轮询实际上根本不是空闲):
doug@s18:~/idle/perf/results/a04$ echo 1 | sudo tee /sys/devices/system/cpu/cpu*/cpuidle/state8/disable
1
doug@s18:~/idle/perf/results/a04$ echo 1 | sudo tee /sys/devices/system/cpu/cpu*/cpuidle/state7/disable
1
doug@s18:~/idle/perf/results/a04$ echo 1 | sudo tee /sys/devices/system/cpu/cpu*/cpuidle/state6/disable
1
doug@s18:~/idle/perf/results/a04$ echo 1 | sudo tee /sys/devices/system/cpu/cpu*/cpuidle/state5/disable
1
doug@s18:~/idle/perf/results/a04$ echo 1 | sudo tee /sys/devices/system/cpu/cpu*/cpuidle/state4/disable
1
doug@s18:~/idle/perf/results/a04$ echo 1 | sudo tee /sys/devices/system/cpu/cpu*/cpuidle/state3/disable
1
doug@s18:~/idle/perf/results/a04$ echo 1 | sudo tee /sys/devices/system/cpu/cpu*/cpuidle/state2/disable
1
doug@s18:~/idle/perf/results/a04$ echo 1 | sudo tee /sys/devices/system/cpu/cpu*/cpuidle/state1/disable
现在 CPU 频率已锁定,功耗并不可怕,主要是因为 turbo 被禁用(turbostat,按照我使用的设置,不区分空闲状态 0 和真正忙碌):
doug@s18:~/c$ sudo ~/turbostat --Summary --quiet --show Busy%,Bzy_MHz,PkgTmp,PkgWatt,GFXWatt,IRQ --interval 6
Busy% Bzy_MHz IRQ PkgTmp PkgWatt GFXWatt
100.26 3700 36069 36 21.66 0.00
100.26 3700 36072 36 21.70 0.00
100.26 3700 36065 36 21.66 0.00
100.26 3700 36079 36 21.89 0.00
100.26 3700 36070 36 21.65 0.00
100.26 3700 36101 36 21.80 0.00
100.26 3700 36072 37 21.74 0.00
附注:实际工作的功率会更高:
doug@s18:~/idle/perf/results/a04$ sudo ~/turbostat --Summary --quiet --show Busy%,Bzy_MHz,PkgTmp,PkgWatt,GFXWatt,IRQ --interval 6
Busy% Bzy_MHz IRQ PkgTmp PkgWatt GFXWatt
100.26 3700 36169 55 72.08 0.00
100.26 3700 36260 55 71.96 0.00
100.26 3700 36074 55 71.97 0.00
100.26 3700 36082 55 71.99 0.00
100.26 3700 36080 56 72.03 0.00
本答案的示例是用 完成的Intel(R) Core(TM) i5-9600K CPU @ 3.70GHz
。读者可能会有不同数量的空闲状态,具体取决于他们的处理器。
测试工作完成后,重新启用所有空闲状态:
doug@s18:~/idle/perf/results/a04$ echo 0 | sudo tee /sys/devices/system/cpu/cpu*/cpuidle/state*/disable
然后检查:
doug@s18:~/idle/perf/results/a04$ grep . /sys/devices/system/cpu/cpu*/cpuidle/state*/disable
/sys/devices/system/cpu/cpu0/cpuidle/state0/disable:0
/sys/devices/system/cpu/cpu0/cpuidle/state1/disable:0
/sys/devices/system/cpu/cpu0/cpuidle/state2/disable:0
...
/sys/devices/system/cpu/cpu5/cpuidle/state6/disable:0
/sys/devices/system/cpu/cpu5/cpuidle/state7/disable:0
/sys/devices/system/cpu/cpu5/cpuidle/state8/disable:0