CPU Frequency Scaling
CPU clock frequency scales up and down with the CPU usage as a way to reduce power usage. On Linux, this behavior is governed by the CPU governor.
The CPU frequency also scales down as a response to high temperature.
Linux's CPU frequency governor
You can check your current CPU governor by running:
# cpupower frequency-info --governors
analyzing CPU 0:
available cpufreq governors: performance powersave
Alternatively, you may check /sys/devices/system/cpu and see the setting for each CPU core.
# cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
performance
performance
performance
performance
performance
performance
Types of scaling governors
Scaling governors are policies that affect the CPU frequency scaling algorithm.
See: https://www.kernel.org/doc/html/v4.14/admin-guide/pm/cpufreq.html
| Governor | A very brief description |
|---|---|
| performance | Run the CPU at the highest frequency, as defined within the scaling_max_freq limit. |
| powersave | Run the CPU at the lowest frequency, as defined within the scaling_min_freq limit. |
| ondemand | Dynamically sets frequency proportional to the load of the CPUs. |
| conservative | Like ondemand, but frequency changes happen in smaller steps. |
| userspace | Run the CPU at user specified frequency, controlled by writing to the scaling_setspeed attribute.
|
Intel Turbo Boost frequency
Some Intel CPUs support a turbo boost frequency where a CPU can clock faster than its stock speed depending on available power and thermal conditions. Refer to the CPU's specification to determine a particular CPU's turbo boost frequency.
I have observed on some compute servers that the CPU will run somewhere between the base frequency and the turbo boost frequency when the temperature is around the mid 70's Celsius when under full load. I'm not sure why this is the case.
Some helpful commands
| Description | Command |
|---|---|
| Get all CPU core frequencies | grep MHz /proc/cpuinfo
|
| Get average CPU core frequency | grep MHz /proc/cpuinfo | awk '{print $4}' | awk '{temp+=$1;n++} END{printf("%f", temp/n);}'
|
| Get max CPU core frequency | grep MHz /proc/cpuinfo | awk '{print $4}' | sort -rn | head -n 1
|
| Get min CPU core frequency | grep MHz /proc/cpuinfo | awk '{print $4}' | sort -n | head -n 1
|
| Get average CPU temperature | cat /sys/class/thermal/thermal_zone*/temp | awk '{temp+=$1;n++} END{printf("%f", temp/n/1000);}'
|
| Get max CPU temperature | cat /sys/class/thermal/thermal_zone*/temp | sort -rn | head -n 1 | awk '{printf("%f", $1/1000);}'
|