CPU frequency scaling enables the operating system to scale the CPU frequency up or down in order to save power. CPU frequencies can be scaled automatically depending on the system load, in response to ACPI events, or manually by userspace programs.

CPU frequency scaling is implemented in Linux kernel, the infrastructure is called cpufreq. Since kernel 3.4 the necessary modules are loaded automatically and the recommended ondemand governor is enabled by default. However, userspace tools like cpupower, acpid, Laptop Mode Tools, or GUI tools provided for your desktop environment, may still be used for advanced configuration.

Userspace tools

cpupower

cpupower is a set of userspace utilities designed to assist with CPU frequency scaling. The package is not required to use scaling, but is highly recommended because it provides useful command-line utilities and a systemd service to change the governor at boot.

The configuration file for cpupower is located in /etc/default/cpupower. This configuration file is read by a bash script in /usr/lib/systemd/scripts/cpupower which is activated by systemd with cpupower.service. You may want to enable cpupower.service to start at boot.

GNOME Shell extensions

Granola

GranolaAUR (available in the AUR) is a daemon that monitors the cpu usage and uses the userspace governor to lessen power usage without any noticeable difference in performance. The default settings will work for most setups.

To test if it works, run:

$ cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq

and check that the CPU frequency is below maximum.

CPU frequency driver

Note:

As of kernel 3.4, the native CPU module is loaded automatically.

Starting with kernel 3.9, the new pstate power scaling driver is used automatically for modern Intel CPUs instead of the other drivers below. This driver takes priority over other drivers and in fact is inbuilt as opposed to being a module. This driver is currently automatically used for Sandy Bridge and Ivy Bridge type CPUs. If you encounter a problem while using this driver, add intel_pstate=disable to your kernel line. You can use the same user space utilities with this driver but cannot control it.

Even P State behavior mentioned above can be influenced with /sys/devices/system/cpu/intel_pstate, e.g. Intel Turbo Boost can be deactivated with # echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo for keeping CPU-Temperatures low.

Additional control for modern Intel CPUs is available with the Linux Thermal Daemon (available as thermaldAUR in the AUR), which proactively controls thermal using P-states, T-states, and the Intel power clamp driver.

Sampling rate

The sampling rate determines how frequently the governor checks to tune the CPU. Setting sampling_down_factor greater than 1 improves performance by reducing the overhead of load evaluation and keeping the CPU at its highest clock frequency due to high load. This tunable has no effect on behavior at lower CPU frequencies/loads.

Interaction with ACPI events

Users may configure scaling governors to switch automatically based on different ACPI events such as connecting the AC adapter or closing a laptop lid. A quick example is given below, however it may be worth reading full article on acpid.

Events are defined in /etc/acpi/handler.sh. If the acpid package is installed, the file should already exist and be executable. For example, to change the scaling governor from performance to conservative when the AC adapter is disconnected and change it back if reconnected:

Privilege granting under GNOME

Note: systemd introduced logind which handles consolekit and policykit actions. The following code below does not work. With logind, simply edit in the file /usr/share/polkit-1/actions/org.gnome.cpufreqselector.policy the <defaults> elements according to your needs and the polkit manual [1].

GNOME has a nice applet to change the governor on the fly. To use it without the need to enter the root password, simply create following file:

Troubleshooting

Some applications, like ntop, do not respond well to automatic frequency scaling. In the case of ntop it can result in segmentation faults and lots of lost information as even the on-demand governor cannot change the frequency quickly enough when a lot of packets suddenly arrive at the monitored network interface that cannot be handled by the current processor speed.

Some CPU's may suffer from poor performance with the default settings of the on-demand governor (e.g. flash videos not playing smoothly or stuttering window animations). Instead of completely disabling frequency scaling to resolve these issues, the aggressiveness of frequency scaling can be increased by lowering the up_thresholdsysctl variable for each CPU. See how to change the on-demand governor's threshold.

Sometimes the on-demand governor may not throttle to the maximum frequency but one step below. This can be solved by setting max_freq value slightly higher than the real maximum. For example, if frequency range of the CPU is from 2.00 GHz to 3.00 GHz, setting max_freq to 3.01 GHz can be a good idea.

Some combinations of ALSA drivers and sound chips may cause audio skipping as the governor changes between frequencies, switching back to a non-changing governor seems to stop the audio skipping.

BIOS frequency limitation

Some CPU/BIOS configurations may have difficulties to scale to the maximum frequency or scale to higher frequencies at all. This is most likely caused by BIOS events telling the OS to limit the frequency resulting in /sys/devices/system/cpu/cpu0/cpufreq/bios_limit set to a lower value.

Either you just made a specific Setting in the BIOS Setup Utility, (Frequency, Thermal Management, etc.) you can blame a buggy/outdated BIOS or the BIOS might have a serious reason for throttling the CPU on it's own.

Reasons like that can be (assuming your machine's a notebook) that the battery is removed (or near death) so you're on AC-power only. In this case a weak AC-source might not supply enough electricity to fulfill extreme peak demands by the overall system and as there is no battery to assist this could lead to data loss, data corruption or in worst case even hardware damage!