Paul Jurczak Asked: 2020-07-06 12:16:06 +0800 CST2020-07-06 12:16:06 +0800 CST 2020-07-06 12:16:06 +0800 CST 使用 CPUFreq Gnome 扩展的固定频率问题 772 我使用 Ubuntu 18.04 在两台不同的 PC 上安装了 CPUFreq Gnome 扩展。一个有一个 Haswell,另一个有一个 Skylake CPU。我将最小和最大频率设置为相等并关闭频率提升。PC 散热良好,CPU 温度低于 40 度。C. Haswell 系统上的频率保持非常稳定,偶尔下降不到 1%,但在 Skylake 系统上经常下降几个百分点,偶尔高达 10%: 上面的终端显示watch grep \"cpu MHz\" /proc/cpuinfo. 我能做些什么让它更稳定吗? power-management gnome cpu 1 个回答 Voted Best Answer Doug Smythies 2020-07-06T12:59:25+08:002020-07-06T12:59:25+08:00 如果负载足够低,即使最小值和最大值都设置为最高级别,处理器也会自行回退 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,用我用的设置,不区分idle state 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
如果负载足够低,即使最小值和最大值都设置为最高级别,处理器也会自行回退 CPU 频率。你不应该注意性能方面的。但是,如果它真的很重要,我所知道的最大锁定 CPU 频率的唯一方法是禁用深度大于 0 的每个空闲状态,但代价是巨大的功率。
因此,对于正常的默认设置:
对于轻负载,您会得到类似的东西:
现在,像您所做的那样进行更改:
实际上,出奇的稳定。并且功率仍然很低:
但是,如果您希望它在 3.7 GHz 时更稳定,则禁用深度空闲状态,这样处理器就不会进入空闲状态(空闲状态 0 或轮询,实际上根本不是空闲):
而且现在CPU频率被锁定了,功率也不可怕,主要是turbo被禁用了(turbostat,用我用的设置,不区分idle state 0和真的很忙):
附带说明一下,实际工作的功率会更高:
这个答案的例子是用
Intel(R) Core(TM) i5-9600K CPU @ 3.70GHz
. 阅读器可能有不同数量的空闲状态,具体取决于它们的处理器。要再次启用所有空闲状态,在测试工作之后:
然后检查: