Problem with fixed frequencies using CPUFreq Gnome extension
I installed CPUFreq Gnome extension on two different PCs with Ubuntu 18.04. One has a Haswell the other one Skylake CPU. I set minimum and maximum frequencies to be equal and turn Frequency Boost off. PCs are well cooled and CPU temperature is below 40 deg. C. Frequency on Haswell system stays very stable with occasional dips less than 1%, but it regularly dips a few percent on Skylake system, occasionally up to 10%:
The terminal above shows output of watch grep \"cpu MHz\" /proc/cpuinfo
.
Is there anything I can do to make it more stable?
Solution 1:
The processor will back off on CPU frequency by itself, if the load is low enough, even with both min and max set to highest level. You shouldn't notice performance wise. However if it really matters the only way that i know of to lock the CPU frequencies at maximum is to disable every idle state deeper than 0, but at the cost of a tremendous amount of power.
So, for normal default settings:
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
you would get something like this for light loads:
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
now, make the changes, as you have done:
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
Actually, surprisingly stable. And power is still low:
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
However, if you want it even more stable at 3.7 GHz, then disable deep idle states, such the processor never goes into idle (idle state 0, or poll, is not actually idle at all):
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
And now the CPU frequencies are locked, the power is not terrible, mainly because turbo is disabled (turbostat, with the setting I used, does not distinguish between idle state 0 and really busy):
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
As a side note, the power for real work will be higher:
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
The examples for this answer were done with Intel(R) Core(TM) i5-9600K CPU @ 3.70GHz
. Readers might have a different number of idle states, depending on their processor.
To enable all idle states again, after the test work:
doug@s18:~/idle/perf/results/a04$ echo 0 | sudo tee /sys/devices/system/cpu/cpu*/cpuidle/state*/disable
And then check:
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