Configuring CPU frequency scaling in Linux balances performance, power consumption, and thermal output for desktops, laptops, and servers. Tuning CPU policies prevents constant maximum clock speeds, reduces fan noise, and can extend battery life while still allowing high performance under load.

The kernel exposes scaling through the cpufreq subsystem, which relies on hardware drivers such as intel_pstate and acpi-cpufreq. Policies and limits are controlled by user-space tools like cpufreq-info and cpufreq-set or directly through the /sys/devices/system/cpu/cpu*/cpufreq directory, where each logical CPU publishes its available governors, current frequency, and allowed range.

Misconfigured frequency policies can degrade performance, increase latency, or lock CPUs at unnecessarily high clocks, so changes should be tested under typical workloads and applied cautiously on production systems.

Steps to set up CPU frequency scaling using cpufreq:

  1. Refresh package metadata on Debian-based systems.
    $ sudo apt update
    Hit:1 http://ports.ubuntu.com/ubuntu-ports noble InRelease
    Hit:2 http://ports.ubuntu.com/ubuntu-ports noble-updates InRelease
    Hit:3 http://ports.ubuntu.com/ubuntu-ports noble-backports InRelease
    Hit:4 http://ports.ubuntu.com/ubuntu-ports noble-security InRelease
    Reading package lists...
    Building dependency tree...
    Reading state information...
    5 packages can be upgraded. Run 'apt list --upgradable' to see them.
  2. Ensure the cpufrequtils package providing cpufreq-info and cpufreq-set is installed on Ubuntu or Debian.
    $ sudo apt install --assume-yes cpufrequtils
    Reading package lists...
    Building dependency tree...
    Reading state information...
    cpufrequtils is already the newest version (008-2build2).
    0 upgraded, 0 newly installed, 0 to remove and 5 not upgraded.

    On other Linux distributions, install the equivalent package with the native package manager.

  3. Display current CPU frequency information and available governors.
    $ cpufreq-info
    cpufrequtils 008: cpufreq-info (C) Dominik Brodowski 2004-2009
    Report errors and bugs to cpufreq@vger.kernel.org, please.
    analyzing CPU 0:
      no or unknown cpufreq driver is active on this CPU
      maximum transition latency: 4294.55 ms.
    analyzing CPU 1:
      no or unknown cpufreq driver is active on this CPU
      maximum transition latency: 4294.55 ms.
    analyzing CPU 2:
      no or unknown cpufreq driver is active on this CPU
      maximum transition latency: 4294.55 ms.
    analyzing CPU 3:
      no or unknown cpufreq driver is active on this CPU
      maximum transition latency: 4294.55 ms.
    analyzing CPU 4:
      no or unknown cpufreq driver is active on this CPU
      maximum transition latency: 4294.55 ms.
    analyzing CPU 5:
      no or unknown cpufreq driver is active on this CPU
      maximum transition latency: 4294.55 ms.
    analyzing CPU 6:
      no or unknown cpufreq driver is active on this CPU
      maximum transition latency: 4294.55 ms.
    analyzing CPU 7:
      no or unknown cpufreq driver is active on this CPU
      maximum transition latency: 4294.55 ms.
    analyzing CPU 8:
      no or unknown cpufreq driver is active on this CPU
      maximum transition latency: 4294.55 ms.
    analyzing CPU 9:
      no or unknown cpufreq driver is active on this CPU
      maximum transition latency: 4294.55 ms.

    If no cpufreq driver is active, frequency scaling controls are not exposed; use a full VM or physical host to manage governors.

  4. Attempt to set a target governor for CPU 0 using cpufreq-set.
    $ sudo cpufreq-set --governor ondemand --cpu 0
    Error setting new values. Common errors:
    - Do you have proper administration rights? (super-user?)
    - Is the governor you requested available and modprobed?
    - Trying to set an invalid policy?
    - Trying to set a specific frequency, but userspace governor is not available,
       for example because of hardware which cannot be set to a specific frequency
       or because the userspace governor isn't loaded?

    When no cpufreq driver is active, governor changes will fail with errors like the above.

Steps to set up CPU frequency scaling using sysfs:

  1. Confirm that the cpufreq directory for CPU 0 is present under /sys/devices/system/cpu.
    $ ls /sys/devices/system/cpu/cpu0/cpufreq/
    ls: cannot access '/sys/devices/system/cpu/cpu0/cpufreq/': No such file or directory

    When the cpufreq sysfs directory is absent, the kernel is not exposing CPU frequency controls in this environment.