Difference between revisions of "Cpufrequtils"

From ArchWiki
Jump to: navigation, search
m
Line 57: Line 57:
  
 
In this case, replace the kernel module <tt>acpi-cpufreq</tt> with <tt>speedstep-centrino</tt>, <tt>p4-clockmod</tt> or <tt>speedstep-ich</tt>.
 
In this case, replace the kernel module <tt>acpi-cpufreq</tt> with <tt>speedstep-centrino</tt>, <tt>p4-clockmod</tt> or <tt>speedstep-ich</tt>.
 +
 +
Notice that the speedstep-centrino module is deprecated.
 +
 +
There is a kernel with the speedstep-centrino module patched on the AUR, it is the '''<tt>kernel26-pentium-m</tt>''' package which is located here: http://aur.archlinux.org/packages.php?ID=33104
  
 
==== AMD ====
 
==== AMD ====

Revision as of 16:10, 28 February 2010

Template:Article summary start Template:Article summary text Template:Article summary heading Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:Article summary heading Template:Article summary wiki Template:Article summary wiki Template:Article summary end

Template:Package Official is a set of utilities designed to assist CPU frequency scaling, a technology used primarily by notebooks that enables the operating system to scale the CPU speed up or down, depending on the current system load and/or power scheme. For instance, CPU frequency scaling can run a 2GHz processor at 1GHz when a notebook is on battery power, thereby conserving battery life and lowering core temperatures.

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

Note that cpufrequtils is not the only way one can manage/throttle one's CPU. powernowd is a simple alternative for adjusting the speed of your CPU depending on system load.

This article covers installation and basic configuration of the cpufrequtils package.

Note: cpufrequtils is not the same as cpufreqd. Never run both cpufreqd and cpufreq daemons.

Installation

The Template:Package Official package is available in the [extra] repository:

# pacman -S cpufrequtils

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)

CPU frequency driver

In order for frequency scaling to work properly, the operating system must first know the limits of the CPU(s). To accomplish this, a kernel module is loaded that can read and manage the specifications of the 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 see a full list of available drivers, run the following:

$ ls /lib/modules/*/kernel/arch/*/kernel/cpu/cpufreq
Tip: For an AMD "K10" CPU like Phenom X4, use the powernow-k8 driver.

To load the CPU frequency driver manually:

Intel

# modprobe acpi-cpufreq

For older Intel CPUs, the command above may return with:

FATAL: Error inserting acpi_cpufreq ([...]/acpi-cpufreq.ko): No such device

In this case, replace the kernel module acpi-cpufreq with speedstep-centrino, p4-clockmod or speedstep-ich.

Notice that the speedstep-centrino module is deprecated.

There is a kernel with the speedstep-centrino module patched on the AUR, it is the kernel26-pentium-m package which is located here: http://aur.archlinux.org/packages.php?ID=33104

AMD

# modprobe powernow-k{6,7,8}

Not all of the powernow-k* drivers may be available or necessary. If loading one of them fails, try loading them individually.

Closing notes

To load the driver automatically at startup, add the appropriate driver to the MODULES array within Template:Filename. For example:

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

Once the appropriate cpufreq driver is loaded, detailed information about the CPU(s) can be displayed by running:

$ cpufreq-info

The output should appear similar to the following:

Template:Command

Monitoring the CPU speed in real-time can be achieved by running:

watch grep \"cpu MHz\" /proc/cpuinfo

Scaling governors

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. One may load as many governors as desired (only one will be active at any given time).

Available governors:

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

Add the desired governor(s) to the MODULES array in Template:Filename:

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

Alternatively, manually set the governor by running the Template:Codeline command (as root). However, this setting will not be saved after a reboot/shutdown. For example:

# cpufreq-set -g ondemand

Run Template:Codeline or Template:Codeline for more information.

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. Events are defined in Template:Filename. If the Template:Package Official package is installed, the file should already exist and be executable. For example, to change the scaling governor from Template:Codeline to Template:Codeline when the AC adapter is disconnected and change it back if reconnected:

Template:File

Changing the Template:Codeline governor's threshold

To change when the Template:Codeline governor switches to a higher multiplier, one can manipulate Template:Filename. Determine the current setting by issuing the following command as root:

# cat /sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold

The value returned should be 95, the default setting as of kernel version 2.6.31. This means that the Template:Codeline governor currently increases the clock rate if a core reaches 95% utilization. The can be changed, for example:

# echo 50 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold

The governor will now switch to a higher clock rate if a core reaches 50% utilization.

To re-apply this setting during boot, add the command to Template:Filename.

Tip: One user found it necessary to use Template:Codeline or the command would fail with a "path not found" message during boot.
Note: Adjusting only Template:Codeline should work fine on multi-core systems, as other entries that belong to the same physical processor are adjusted automatically.

Daemon mode

cpufrequtils also installs a daemon which allows users 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 Template:Filename as root, selecting the desired governor and setting the min/max speed for your CPU(s), for example:

Template:File

Note: The exact min/max values of the CPU(s) can be determined by running Template:Codeline after loading the CPU driver (e.g. Template:Codeline). However, these values are optional. Users may omit them entirely by deleting or commenting out the min/max_freq lines; scaling will work automatically.

With the appropriate configuration, start the daemon with the following command:

# /etc/rc.d/cpufreq start

To start the daemon automatically at startup, add Template:Codeline to the DAEMONS array in Template:Filename, for example:

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

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 Template:Codeline governor cannot change the frequency quickly enough when a lot of packages suddenly arrive at the monitored network interface that cannot be handled by the current processor speed.
  • Some CPUs may suffer from poor performance with the default settings of the Template:Codeline 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_threshold sysctl variable for each CPU. See #Changing the ondemand governor's threshold.