Modern multi-core processors operate within dynamic power envelopes, continuously modulating clock speeds and operating voltages based on system workload demands. In Ubuntu, the Linux kernel manages dynamic frequency transitions via the CPUFreq subsystem using algorithmic management policies known as scaling governors. While desktop distributions typically activate balanced power profiles by default, users executing computationally intensive compilation jobs, database benchmarks, or real-time audio workflows often require maximum clock frequencies. Conversely, laptop users prioritizing battery longevity need to restrict clock ceilings.
Understanding how to inspect, modify, and persist CPU frequency scaling governors in Ubuntu allows you to optimize system responsiveness, manage thermal throttling, and regulate hardware power consumption directly from the command line.
Overview of Standard CPU Frequency Scaling Governors
The Linux kernel CPUFreq driver architecture incorporates several distinct governor algorithms:
- performance: Clamps all processor cores to their maximum supported clock frequency, eliminating scaling latency and providing maximum throughput for intensive computational workloads.
- powersave: Locks processor cores to their minimum rated operating frequency, substantially reducing electrical draw and heat generation at the cost of processing speed.
- schedutil: The modern default governor in contemporary Linux kernels. Integrates directly with the system task scheduler to adjust core frequencies dynamically according to active CPU run-queue load.
- ondemand: A legacy dynamic governor that rapidly scales processor clock speeds to maximum upon detecting workload spikes, then gradually steps down as loads diminish.
- conservative: Similar to ondemand, but steps clock frequencies up and down gradually to conserve energy on battery-powered devices.
Inspecting Active Governors and Supported CPU Drivers
Before applying new scaling profiles, determine which driver regulates your processor architecture:
- Open a terminal shell and query the active governor across all CPU cores:
cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
- Check which scaling driver is active (for example,
intel_pstatefor modern Intel chips,amd-pstatefor recent AMD Ryzen platforms, or genericacpi-cpufreq):
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_driver
- List all available governors supported by your active hardware driver:
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
Installing cpupower Tools and Switching Governors Dynamically
The native cpupower suite provides comprehensive diagnostic and frequency management commands:
- Install the Linux kernel processor utilities:
sudo apt update && sudo apt install -y linux-tools-common linux-tools-$(uname -r)
- Display detailed real-time frequency limits, hardware boosts, and core states:
sudo cpupower frequency-info
- To lock all CPU cores into maximum performance mode immediately:
sudo cpupower frequency-set -g performance
- To switch all cores to power-saving mode for extended mobile battery runtime:
sudo cpupower frequency-set -g powersave
- To target a specific individual CPU core (for instance, reserving core 0 for performance while keeping others balanced):
sudo cpupower -c 0 frequency-set -g performance
Configuring Persistent Governor Policies Across System Reboots
Direct commands issued via cpupower apply immediately to the running kernel, but revert to system defaults upon reboot. To ensure your preferred governor activates automatically on startup:
- Create a dedicated systemd service unit file:
sudo nano /etc/systemd/system/cpu-governor.service
- Paste the following service definition:
[Unit]
Description=Set CPU Frequency Scaling Governor
After=syslog.target
[Service]
Type=oneshot
ExecStart=/usr/bin/cpupower frequency-set -g performance
[Install]
WantedBy=multi-user.target
- Reload the systemd manager configuration and enable the service:
sudo systemctl daemon-reload
sudo systemctl enable --now cpu-governor.service
Upon rebooting, the systemd unit will enforce the specified governor profile across all CPU cores automatically.