Managing CPU Frequency Scaling via Sysfs in Linux

The cpufreq infrastructure in Linux allows for dynamic adjustment of processor clock speeds to balance performance and power consumption. This subsystem exports its configuration through the sysfs interface, usually found at /sys/devices/system/cpu/cpu[N]/cpufreq/. By modifying specific files in this directory, users can control how the kernel scales CPU frequency.\n\n### Scaling Governors\n\nGovernors represent the scaling logic applied to the CPU. The most common types include:\n\n* performance: Forces the CPU to operate at its maximum suppported frequency (scaling_max_freq) regardless of system load.\n* powersave: Keeps the CPU at its minimum frequency (scaling_min_freq) to prioritize energy efficiency over speed.\n* userspace: Hand over frequency control to a user-level program. This allows for manual frequency setting via the scaling_setspeed file.\n* ondemand: A dynamic governor that jumps to the maximum frequency as soon as a load threshold is met, then gradually scales down as the CPU becomes idle.\n* conservative: Similar to ondemand but more gradual. It increments or decrements frequency in steps rather than jumping directly to the maximum, resulting in smoother transitions.\n* interactive: Optimized for latency-sensitive workloads. It scales frequency based on bursts of activity to ensure the UI remains responsive.\n\n### Inspecting and Modifying Settings\n\nTo check which governor is currently active for a specific core (e.g., CPU 0), read the scaling_governor file:\n\nbash\ncat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor\n\n\nTo switch to a different governor, such as performance, write the name of the governor to that same file:\n\nbash\necho "performance" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor\n\n\n### Key Sysfs Attributes\n\nThe following files provide detailed information about the CPU's capabilities and current state:\n\n* cpuinfo_cur_freq: The hardware's current operating frequency in kHz.\n* cpuinfo_max_freq / cpuinfo_min_freq: The absolute hardware limits of the processor.\n* scaling_available_governors: Lists all governors compiled into the kernel or loaded as modules.\n* scaling_available_frequencies: Lists all discrete frequency steps supported by the CPU driver.\n* scaling_cur_freq: The frequency currently requested by the governor.\n* scaling_max_freq / scaling_min_freq: Sets the software-defined bounds for the governor. Changing these values restricts the range in which the governor can operate.\n* scaling_driver: Identifies the driver currently managing the CPU scaling (e.g., intel_pstate or acpi-cpufreq).\n* cpuinfo_transition_latency: The time required to switch between two different frequencies, measured in nanoseconds.

Tags: Linux kernel CPU Performance Tuning sysfs

Posted on Wed, 05 Aug 2026 16:37:27 +0000 by northernmonkey