Ubuntu 20.04. overclocks intel i7-9700k automatically?
I have a new intel i7-9700k running in ubuntu 20.04. This processor should clock at base frequency 3.6 GHz with maximum frequency 4.9 GHz in overclocking.
I did an expensive computation today and took a look at the clock frequencies with
watch -n.1 "cat /proc/cpuinfo | grep \"^[c]pu MHz\""and the cpu kernels clocked at ~4.5 GHz. How can this be? I didn't change the BIOS settings? The temperatures where in the normal range according to lm-sensors (below 80 'C mostly). By demand :
cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_driverreturns
intel_pstate
intel_pstate
intel_pstate
intel_pstate
intel_pstate
intel_pstate
intel_pstate
intel_pstateand
cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governorreturns
powersave
powersave
powersave
powersave
powersave
powersave
powersave
powersave 2 2 Answers
when busy
When you ran your "expensive computation" There are several reasons why your CPU's might not get to 4.9 GHz, but rather only get to ~4.5 Ghz. One likely reason, particularly if your application is multi-threaded is the typical max frequency reduction as a function of how many cores are active. Example (i7-2600K), excerpt from turbostat:cpu1: MSR_TURBO_RATIO_LIMIT: 0x23242526
35 * 100.0 = 3500.0 MHz max turbo 4 active cores
36 * 100.0 = 3600.0 MHz max turbo 3 active cores
37 * 100.0 = 3700.0 MHz max turbo 2 active cores
38 * 100.0 = 3800.0 MHz max turbo 1 active coresTypically is is highly unusual to see this (i5-9600K, but this is not the default for the processor, I did it in BIOS):
cpu3: MSR_TURBO_RATIO_LIMIT: 0x2b2b2e2e2e2e2e2e
43 * 100.0 = 4300.0 MHz max turbo 8 active cores <<< I don't have 8 cores
43 * 100.0 = 4300.0 MHz max turbo 7 active cores <<< I don't have 7 cores
46 * 100.0 = 4600.0 MHz max turbo 6 active cores
46 * 100.0 = 4600.0 MHz max turbo 5 active cores
46 * 100.0 = 4600.0 MHz max turbo 4 active cores
46 * 100.0 = 4600.0 MHz max turbo 3 active cores
46 * 100.0 = 4600.0 MHz max turbo 2 active cores
46 * 100.0 = 4600.0 MHz max turbo 1 active coresOther reasons include your power bias settings, I/O waits, power or thermal throttling (you mentioned thermal is not the issue, but just saying). If you want the most you can get use performance governor instead of the powersave governor. While many recommend higher level tools, I use primitives:
doug@s18:~/c$ cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
powersave
powersave
powersave
powersave
powersave
powersave
doug@s18:~/c$ echo performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
performance
doug@s18:~/c$ cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
performance
performance
performance
performance
performance
performancewhen idle
When one samples the CPUs at such a high rate, 10 times per second, often the command itself has an effect on the system resulting in a bias in what is observed. Keep in mind that idle CPUs can go into very deep idle states for several seconds at a time, and wakeing them at a high rate just to sample the frequency is not a good idea, yet extremely common among users. If you want to know what is going on with your system, then I would suggest tubostat for two reasons: It is a really good tool; It is also the preferred tool for upstream escalations. But please sample slowly. Example (mostly, I find summary information good enough, but you can drill down into a lot of information. I left the HWP related lines from the initial spew of information):
$ sudo turbostat --Summary --show Busy%,Bzy_MHz,PkgTmp,PkgWatt,GFXWatt,IRQ --interval 6
...
CPUID(6): APERF, TURBO, DTS, PTM, HWP, HWPnotify, HWPwindow, HWPepp, No-HWPpkg, EPB
...
cpu0: MSR_PM_ENABLE: 0x00000001 (HWP)
cpu0: MSR_HWP_CAPABILITIES: 0x0109252e (high 46 guar 37 eff 9 low 1)
cpu0: MSR_HWP_REQUEST: 0x8000ff01 (min 1 max 255 des 0 epp 0x80 window 0x0 pkg 0x0)
cpu0: MSR_HWP_INTERRUPT: 0x00000001 (EN_Guaranteed_Perf_Change, Dis_Excursion_Min)
...
Busy% Bzy_MHz IRQ PkgTmp PkgWatt GFXWatt
0.03 956 262 31 1.82 0.00
0.03 800 122 31 1.85 0.00 <<< Notice the busy % and low CPU freq.
0.03 800 131 32 1.86 0.00
0.03 800 166 31 1.86 0.00
0.03 800 140 31 1.86 0.00
0.03 800 128 31 1.83 0.00
0.03 800 128 31 1.78 0.00
0.02 800 99 31 1.75 0.00
0.03 800 139 31 1.78 0.00
0.02 800 108 31 1.58 0.00
0.03 800 144 31 1.66 0.00
0.03 800 121 31 1.72 0.00Now, just because in your case you are seeing much higher CPU frequencies, it doesn't mean your power consumption is much, if any, higher. If the frequency is higher the CPU also finishes its work faster, and it goes back to sleep sooner and for longer. Example:
Busy% Bzy_MHz IRQ PkgTmp PkgWatt GFXWatt
0.02 800 100 31 1.90 0.00 <<< notice slightly different baseline than above (different kernel today)
0.02 800 93 31 1.90 0.00
0.03 800 130 31 1.90 0.00
0.05 800 208 31 1.90 0.00
0.04 800 169 31 1.90 0.00
0.05 1069 199 31 1.91 0.00
0.06 1904 285 31 1.94 0.00
0.00 4548 98 31 1.93 0.00
0.00 4600 89 32 1.93 0.00
0.01 4545 129 32 1.93 0.00 <<< Cost was about 0.03 watts.
0.00 4601 109 31 1.93 0.00
0.01 4559 140 31 1.94 0.00 I read your question that you are surprised to see such high frequency values. The selection of core speeds is not simple. You can get more details by typing the command cpufreq-info. It should show you under current policy that your governor can select between 800 MHz and 4.90 GHz or similar. (My CPU is a i9-9900K and shows between 800 MHz and 5.00 GHz.)
If you really want to limit the frequency further, you can use cpufreq-set.