devutils/ATFQ/book ATFQ git

Part I · How it works

2.4 Clock speed, turbo and power saving

alsocpu frequencyclock speedghzturboturbo boostboostgovernorcpufreqscaling governorc-statescpuidlethrottlingthermal throttlingcpu temperaturepowersave

TL;DR

  • A CPU's speed changes all the time: it climbs when there's work, drops when idle, and goes above its base frequency (turbo) while power and heat allow.
  • The kernel's cpufreq driver and governor pick the speed; idle CPUs drop into sleep states (C-states), deeper ones saving more but waking slower.
  • Too hot, and the CPU slows itself down (thermal throttling): a laptop can lose half its speed under a long load.
grep MHz /proc/cpuinfo                # current speed of each CPU (x86)
cpupower frequency-info               # driver, governor, limits
sensors                               # temperatures (package lm_sensors)

On your machine

alice@laptopexample
$ atfq 2.4
  Driver    intel_pstate, governor powersave
  Range     400 MHz to 4.7 GHz
  Now       400 MHz to 4.1 GHz across 8 CPUs
  Turbo     allowed
  Idle      intel_idle: POLL 51,234, C1E 2.4 million, C6 1.8 million, C8
            950,000, C10 14.2 million (CPU 0, times entered)
  CPU temp  58 °C (x86_pkg_temp)

An example: Alice's laptop, one of the test machines. In your terminal, this block shows your own machine, read live.

Pitfalls

Deep dive 2 questions

Why not always run at full speed?

Power grows much faster than frequency: a higher clock needs a higher voltage, and power rises with the square of the voltage. Running a burst fast and then sleeping deeply ("race to idle") often costs less energy than running slowly for longer. Turbo exploits the other side: the chip is allowed to exceed its sustained power limit for a short while, until heat builds up.

What are C-states?

C0 is running. In C1 the core stops its clock but wakes almost instantly; deeper states turn off caches and power, and take tens or hundreds of microseconds to wake. The cpuidle governor guesses how long the CPU will stay idle and picks the deepest state worth it. For very latency-sensitive work, limiting deep states trades power for reactivity.

Commands
cpupower sensors grep
Paths
/sys/devices/system/cpu/cpu0/cpufreq/ /sys/class/thermal/
See also
18. CPU
2.2 Cores, threads and sockets
18.1 Load average