[2024-feb-29] Sad news: Eric Layton aka Nocturnal Slacker aka vtel57 passed away on Feb 26th, shortly after hospitalization. He was one of our Wiki's most prominent admins. He will be missed.

Welcome to the Slackware Documentation Project

This is an old revision of the document!


CPU-frequency scaling on Slackware

Overview

CPU frequency scaling is carried out by the kernel, but requires that the relevant UEFI/BIOS options be enabled, such as Intel (Enhanced) Speedstep. Slackware comes with all requirements necessary to use this feature.

Kernel Config Requirements

The kernel options for CPU frequency scaling are as follows. You need both a governor (one set to default) and a driver. The Slackware default governor is 'userspace'.

  • Power management and ACPI options
    • CPU Frequency scaling
      • CPU Frequency scaling (CPU_FREQ [=y])
        • 'performance' governor (CONFIG_CPU_FREQ_GOV_PERFORMANCE) This sets CPU frequency to the maximum available.
        • 'powersave' governor (CONFIG_CPU_FREQ_GOV_POWERSAVE) This sets CPU frequency to the minimum available.
        • 'userspace' governor for userspace frequency scaling (CONFIG_CPU_FREQ_GOV_USERSPACE) This allows userspace programs to set the CPU frequency.
        • 'ondemand' cpufreq policy governor (CONFIG_CPU_FREQ_GOV_ONDEMAND) This governor is recommended for desktops.
        • 'conservative' cpufreq governor (CONFIG_CPU_FREQ_GOV_CONSERVATIVE) This governor is recommended for laptops/netbooks. Although similar to the 'ondemand' governor, frequency is gracefully increased and decreased rather than jumping to 100% when speed is required.
        • x86 CPU frequency scaling drivers
          • Intel P state control (X86_INTEL_PSTATE [=n]) This driver is mutually exclusive with CONFIG_X86_ACPI_CPUFREQ. It is a newer driver for Sandy Bridge processors and may cause problems.
          • Processor Clocking Control interface driver (CONFIG_X86_PCC_CPUFREQ) This is only required for HP ProLiant servers, which using this interface. Otherwise, disable it.
          • ACPI Processor P-States driver (CONFIG_X86_ACPI_CPUFREQ [=y]) This is the recommended driver for newer CPUs Intel (Enhanced) Speedstep enabled and AMD K10 and newer.
          • AMD Opteron/Athlon64 PowerNow! (CONFIG_X86_POWERNOW_K8) This is for K8/early Opteron/Athlon64 processors.
          • Intel Enhanced SpeedStep (deprecated) (CONFIG_X86_SPEEDSTEP_CENTRINO [=n] This is a deprecated option that has been superseded by CONFIG_X86_ACPI_CPUFREQ, so leave this disabled.
          • Intel Pentium 4 clock modulation (CONFIG_X86_P4_CLOCKMOD [=n]) This is a hack for Pentium 4s that may cause severe slowdowns and noticeable latencies, so disable it.
It is recommended that the drivers be built-in to the kernel. If they are not, they may load automatically or you may have to load them yourself.

Checking the CPU frequency settings

Slackware comes with the cpufrequtils package which helps to configure frequency scaling in an appropriate manner. You can check the settings on your system with the command

cpufreq-info

Or if you don't have the package installed:

cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
cat /proc/cpuinfo

where “cpu*” is the CPU you want the info on, for example cpu0.

Setting the CPU frequency settings

The cpufreq-set command can be used to set the appropriate governor.

Adding the following to the /etc/rc.d/rc.local file

# CPU-frequency scaling
cpufreq-set --cpu 0 --governor conservative
cpufreq-set --cpu 1 --governor conservative

will set the governor to 'conservative' on each boot.

The same can be done using sysfs:

echo "conservative" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo "conservative" > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor

If you have Turbo Boost enabled in the UEFI/BIOS, you can turn boost on (1) or off (0) by running:

echo 1 > /sys/devices/system/cpu/cpufreq/boost

as long as the interface exists.

Further reading

The manpages for cpufreq-info and cpufreq-set are useful.

The kernel Documentation/cpu-freq directory contains detailed explanations of CPU frequency drivers, governors, and other settings.

A decent explanation of P states and how they are handled in the kernel: https://plus.google.com/+ArjanvandeVen/posts/dLn9T4ehywL

Sources

 howtos:hardware:cpu_frequency_scaling ()