Set CPU Governor to Performance Using cpupower

The Linux operating system balances power efficiency and computing speed through CPU frequency scaling governors, managed primarily through the user-space cpupower utility. This article explains the underlying mechanism of the Linux CPU frequency subsystem (cpufreq), how the performance governor operates, and the exact process the kernel and cpupower use to force processor cores to operate at their maximum frequency states.

The Linux Frequency Scaling Architecture

At the core of Linux CPU management is the cpufreq infrastructure located in the kernel. This subsystem interfaces with hardware-specific drivers (such as intel_pstate, amd_pstate, or generic drivers like acpi-cpufreq) to adjust processor clock speeds dynamically.

The kernel exposes this functionality to user space through the virtual filesystem sysfs, specifically under /sys/devices/system/cpu/cpu*/cpufreq/. Key virtual files within this directory include:

How the Performance Governor Works

A scaling governor is a kernel algorithm that decides what frequency the CPU should run at based on current system conditions. While governors like powersave, ondemand, or schedutil scale clock speeds up and down based on workload and energy targets, the performance governor disables dynamic downclocking.

When the performance governor is active:

The Role of the cpupower Utility

The cpupower utility is part of the Linux kernel source tree (under tools/power/cpupower) and acts as a standardized user-space interface. Rather than requiring administrators to manually write strings into individual sysfs files for dozens of logical cores, cpupower abstracts these hardware controls.

When you execute a command to change policies, cpupower reads system capabilities via the sysfs tree, validates the requested parameters, and makes the appropriate kernel system calls to write the values across all specified CPU cores simultaneously.

Setting the Governor to Performance

To view the current governor, available drivers, and frequency limits on all cores, query the system using:

cpupower frequency-info

To switch all CPU cores to the performance governor, run:

sudo cpupower frequency-set -g performance

When this command runs, cpupower performs the equivalent of iterating through every core on the system and writing performance directly to each core's sysfs path:

echo "performance" | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor

You can verify that the change took effect across the system with:

cpupower frequency-info | grep "active governor"

Making the Configuration Persistent

Changes made directly by cpupower apply immediately to the runtime environment but do not persist across system reboots. To maintain the performance governor permanently, modern Linux distributions utilize systemd.

Most distributions package a cpupower.service file. You can configure the desired governor by editing its configuration file (typically located at /etc/default/cpupower or /etc/cpupower.conf):

governor='performance'

Once configured, enable and start the service so systemd applies the settings during the boot sequence:

sudo systemctl enable --now cpupower.service

During initialization, systemd executes cpupower before multi-user targets are reached, ensuring the kernel locks processor cores to their maximum capability from boot.