Cpufrequtils

From ArchWiki

Jump to: navigation, search


i18n
English
Русский
Español
Português

Contents

[edit] Summary

Cpufrequtils is a set of utilities designed to assist CPU Frequency Scaling, a technology used primarily by notebooks which enables the OS to scale the CPU speed up or down, depending on the current system load and/or power scheme. For instance, CPU frequency scaling can reduce a 2Ghz processor down to 1Ghz when a notebook is on battery power, thereby conserving battery life, reducing heat and lowering fan noise.

When used in conjunction with Pm-utils, notebook owners are provided with a complete power management suite.

[edit] Installation

The cpufrequtils package is available from the Extra repository:

# pacman -S cpufrequtils

[edit] Configuration

Configuring CPU scaling is a 3-part process:

  1. Load appropriate CPU frequency driver
  2. Load desired scaling governor(s)
  3. Configure and load frequency scaling daemon (optional)

[edit] CPU Frequency Driver

In order for frequency scaling to work properly, the OS must first know the limits of your CPU(s). To do this, we load a kernel driver that can read and manage the specifications of your CPU(s).

Most modern notebooks and desktops can simply use the acpi-cpufreq driver, however other options include the p4-clockmod, powernow-k6, powernow-k7, powernow-k8, and speedstep-centrino drivers.

To load the CPU Frequency driver manually:

# modprobe acpi-cpufreq

To load the driver automatically at startup, add the appropriate driver to the MODULES array within /etc/rc.conf. For example:

MODULES=( acpi-cpufreq vboxdrv fuse fglrx iwl3945 ... )

Once the appropriate cpufreq driver is loaded, you can view detailed information about your CPU(s) by running:

$ cpufreq-info

Sample output of cpufreq-info (from an Intel Duo Core T2500):

analyzing CPU 0:
 driver: acpi-cpufreq
 CPUs which need to switch frequency at the same time: 0 1
 hardware limits: 1000 MHz - 2.00 GHz
 available frequency steps: 2.00 GHz, 1.67 GHz, 1.33 GHz, 1000 MHz
 available cpufreq governors: ondemand, performance
 current policy: frequency should be within 1000 MHz and 2.00 GHz.
                 The governor "performance" may decide which speed to use
                 within this range.
 current CPU frequency is 2.00 GHz.
analyzing CPU 1:
 driver: acpi-cpufreq
 CPUs which need to switch frequency at the same time: 0 1
 hardware limits: 1000 MHz - 2.00 GHz
 available frequency steps: 2.00 GHz, 1.67 GHz, 1.33 GHz, 1000 MHz
 available cpufreq governors: ondemand, performance
 current policy: frequency should be within 1000 MHz and 2.00 GHz.
                 The governor "performance" may decide which speed to use
                 within this range.
 current CPU frequency is 2.00 GHz.

[edit] Scaling Governors (CPU Power Schemes)

Governors can be thought of as pre-configured power schemes for the CPU. These governors must be loaded as kernel modules in order to be seen by such programs as kpowersave and gnome-power-manager. You may load as many governors as you like, however only one will be active at any given time.

Available governors:

  • performance (default) -- The performance governor is built into the kernel and runs the CPU(s) at maximum clock speed
  • cpufreq_ondemand (recommended) -- Dynamically increases/decreases the CPU(s) clock speed based on system load
  • cpufreq_conservative -- Similar to ondemand, but more conservative (clock speed changes are more graceful)
  • cpufreq_powersave -- Runs the CPU at minimum speed
  • cpufreq_userspace -- Manually configured clock speeds by user

Add the desired governor(s) to the MODULES array in /etc/rc.conf:

MODULES=(acpi-cpufreq cpufreq_ondemand cpufreq_powersave vboxdrv fuse fglrx iwl3945 ... )

Alternatively, you can manually set the governor by running the cpufreq-set command (as root), however this setting will not be saved after a reboot/shutdown. For example:

# cpufreq-set -g ondemand

Run cpufreq-set --help or man cpufreq-set for more information.

[edit] Daemon Mode

cpufrequtils also installs a daemon which will allow you to set the desired scaling governor and min/max clock speeds at boot-time, without the need for additional tools such as kpowersave. This is a perfect solution for those running a lightweight desktop, such as Openbox.

Before starting the daemon, edit /etc/conf.d/cpufreq as root, selecting the desired governor and setting the min/max speed for your CPU(s), for example:

#configuration for cpufreq control
# valid governors:
#  ondemand, performance, powersave,
#  conservative, userspace
governor="ondemand"

# valid suffixes: Hz, kHz (default), MHz, GHz, THz
min_freq="1GHz"
max_freq="2GHz"

Note: The exact min/max values of your CPU(s) can be found running cpufreq-info after loading the CPU driver from above (e.g. modprobe acpi-cpufreq). However, these values are optional. You may omit them entirely by deleting or commenting out the min/max_freq lines. Things will work automatically.

With the config file taken care of, you may now start the daemon with the following command:

# /etc/rc.d/cpufreq start

To start the daemon automatically at startup, add cpufreq to the DAEMONS array in /etc/rc.conf, for example:

DAEMONS=(syslog-ng hal cpufreq dhcdbd networkmanager !network !netfs @alsa @crond @cups @fam @ntpd @sshd)

[edit] Other Resources

CPU_Frequency_Scaling - Other useful info for desktop environment users (Arch Wiki Entry)
Pm-utils - Hibernate/Suspend framework provided by the OpenSUSE community (Arch Wiki Entry)

Personal tools