[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.

Configuring the kernel

Cpu frequency scaling can be done automatically by a so-called governor, or manually. The governors available are “conservative”, “ondemand”, “powersave” and “performance”. When you build your own kernel, you can choose one of these governors or “userspace” which allows for configuring cpu frequency in userspace. The stock Slackware kernels are configured for “userspace” by default.

Checking the cpu frequency settings on your computer

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 using sysfs:

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

where “cpu*” per cpu subdir.

The configuration

The cpufrequtils package provides two commands. With cpufreq-info you can find out which governor is configured and also some other information, for example, the available frequencies for your processor. The cpufreq-set command can be used to set the appropriate governor.

Example

On my laptop I have the following lines in my /etc/rc.d/rc.local file

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

If 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

I recommend reading the manpages for cpufreq-info and cpufreq-set. Also you can read the relevant documentation in the kernel sources.

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 ()