CPU frequency scaling is a power management technique that adjusts the CPU speed dynamically to balance performance and power consumption. It is controlled by CPU governors.
A governor is a kernel module that determines how CPU frequency is adjusted. Different governors are available:
| Governor | Description |
|---|---|
performance |
Runs CPU at max speed always. Best for high-performance tasks. |
powersave |
Runs CPU at minimum speed to save power. |
ondemand |
Increases speed when needed, but lowers it when idle. |
conservative |
Like ondemand, but increases speed gradually. |
schedutil |
Uses kernel scheduler to adjust CPU dynamically (modern method). |
userspace |
Allows manual frequency setting by users or scripts. |
A modern tool for managing CPU frequency and power states.
- Ubuntu/Debian
sudo apt install linux-tools-common linux-tools-$(uname -r) -y - RHEL/CentOS/Rocky Linux
sudo dnf install kernel-tools -y
- Check Current CPU Frequency Info
cpupower frequency-info
- Set CPU Governor to Performance Mode
sudo cpupower frequency-set -g performance
- Set CPU Governor to Power-Saving Mode
sudo cpupower frequency-set -g powersave
- Manually Set CPU Frequency
sudo cpupower frequency-set -f 2.5GHz
An older tool from cpufrequtils package for CPU frequency control.
- Ubuntu/Debian
sudo apt install cpufrequtils -y
- RHEL/CentOS
sudo yum install cpufrequtils -y
- Check Available Governors
cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_available_governors - Set Performance Governor
sudo cpufreq-set -g performance
- Set Maximum CPU Frequency
sudo cpufreq-set -u 3.0GHz
- Set Minimum CPU Frequency
sudo cpufreq-set -d 1.5GHz
- Provides detailed CPU power consumption and frequency information.
- Install:
sudo apt install linux-tools-$(uname -r) - Run:
sudo turbostat
- Helps identify power-hungry processes.
- Install:
sudo apt install powertop
- Run:
sudo powertop
- Dynamically adjusts CPU speed based on load.
- Install:
sudo apt install auto-cpufreq
- Run:
sudo auto-cpufreq --monitor
cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governoror
cpupower frequency-infosudo cpupower frequency-set -g performanceUseful for:
✅ Compiling code (e.g., building Glibc)
✅ Gaming & high-performance applications
✅ Virtual machines requiring stable performance
sudo cpupower frequency-set -g ondemand✅ Extends battery life on laptops
✅ Reduces CPU heat & fan noise
Add the command to /etc/rc.local or create a systemd service.
1️⃣ Create a script:
sudo nano /etc/init.d/cpufreq_performanceAdd:
#!/bin/bash
cpupower frequency-set -g performanceSave & exit.
2️⃣ Make it executable:
sudo chmod +x /etc/init.d/cpufreq_performance3️⃣ Enable at startup:
sudo update-rc.d cpufreq_performance defaults- Install:
sudo apt install linux-tools-common cpufrequtils -y
- Add commands to
/etc/rc.local - Use systemd service to apply settings on boot
- Check if another power management tool (like TLP) is overriding settings:
If running, stop and disable it:
sudo systemctl status tlp
sudo systemctl stop tlp sudo systemctl disable tlp
✅ Use performance mode when compiling or running heavy workloads.
✅ Use ondemand or powersave mode for general use and laptops.
✅ Monitor CPU load and frequency using htop or turbostat.
✅ Automate CPU settings using systemd or boot scripts.
✅ Regularly check CPU temperature and power consumption to optimize efficiency.
- CPU governors control frequency scaling.
- Use
cpupowerorcpufreq-setto manage CPU frequency. - System admins should automate settings using scripts/systemd.
- Monitor CPU power and temperature for optimal performance.
🚀 Let me know if you need further guidance!