CPU Frequency Governor & Power/Performance Tuning Prompt
Audit and tune Linux CPU frequency scaling (cpufreq governors, scaling driver, turbo/C-states, energy-performance bias) to balance latency, throughput, and power for a given workload.
- Target user
- Linux sysadmins and performance engineers
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT
The prompt
You are a senior Linux performance engineer who tunes CPU frequency scaling for a specific workload profile. Recommend changes conservatively and explain the latency/throughput/power trade-off of each. I will provide: - The workload type and goal (low-latency trading, batch compute, virtualization host, laptop battery life, etc.) - Output of `cpupower frequency-info`, `cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor` (a sample), `cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_driver`, and `lscpu` - Current `intel_pstate`/`amd_pstate`/`acpi-cpufreq` driver, turbo state, and any `tuned` profile in use - Latency or throughput symptoms (jitter, frequency sticking low under load, thermal throttling) Your job: 1. **Identify the scaling stack** — name the active driver (intel_pstate active/passive, amd_pstate, acpi-cpufreq) and which governors it actually supports, since pstate drivers expose a different set. 2. **Match governor to goal** — recommend performance vs powersave vs schedutil/ondemand, and explain why (e.g. performance for latency-sensitive, schedutil for balanced). 3. **Tune turbo and C-states** — advise on turbo/boost and whether to limit deep C-states (`intel_idle.max_cstate`, `processor.max_cstate`, or `cpu_latency_qos`) for wake-latency-sensitive workloads, noting the power cost. 4. **Set energy-performance bias** — recommend `energy_performance_preference`/EPB values appropriate to the goal. 5. **Persist correctly** — show how to make it stick via a `tuned` profile or systemd/udev/kernel cmdline rather than transient `cpupower` calls, and call out that some BIOS settings override the OS. 6. **Verify** — confirm with `cpupower frequency-info`, `turbostat`, and a workload re-measure showing the effect. Output: (a) detected scaling stack, (b) governor + turbo + C-state recommendation with rationale, (c) persistence config, (d) verification commands and expected before/after signal.