{{Tip|There is a desktop-privileges package in the AUR (http://aur.archlinux.org/packages.php?ID=42669) that contains a similar .pkla file for authorizing all users of the power group to change te govenor}}

+

There is a desktop-privileges package in the AUR (http://aur.archlinux.org/packages.php?ID=42669) that contains a similar .pkla file for authorizing all users of the power group to change the governor.

===Laptop Mode Tools===

===Laptop Mode Tools===

Revision as of 00:57, 3 March 2011

This template has only maintenance purposes. For linking to local translations please use interlanguage links, see Help:i18n#Interlanguage links.

cpufreq refers to the kernel infrastructure that implements 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.

In order to use scaling, the needed modules have to be loaded and then a governor has to be set. cpufrequtils, acpid and laptop-mode-tools each offer different ways of managing cpufreq. You can also use the simple CPU frequency applets included with some desktop environments instead.

cpufrequtils

Template:Package Official is a set of userspace utilities designed to assist with CPU frequency scaling. The package isn't required to use scaling, but is highly recommended because it provides useful command-line utilities and a daemon script to set the governor at boot.

Template:Package Official provides similar information to the cpufreq-info utility in this package, but not at the same level of detail.

Configuration

Configuring CPU scaling is a 3-part process:

Load appropriate CPU frequency driver

Load desired scaling governor(s)

Select a method to manage switching the governor: manually (via /sys or cpufreq-set), the cpufrequtils #Daemon, laptop-mode-tools, acpid or using an applet/desktop environment. Different methods can be combined if desired.

Optionally, the scaling governor can be tuned with cpufrequtils and/or the /sys interface.

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-k8, and speedstep-centrino drivers. To see a full list of available drivers, run the following:

Laptop Mode Tools

If you are already using or plan to use Laptop Mode Tools for other power saving solutions, you may want to let it manage also CPU frequency scaling.
In that case you just have to insert the acpi-cpufreq module to the MODULES array in Template:Filename:

MODULES=(acpi-cpufreq)

And then go through the Template:Filename to define governors, frequencies and policies.

If you use laptop-mode-tools to manage cpufrequtils, then you won't need to load other modules and daemons or to set up scaling governors and interaction with ACPI events. Please refer to Laptop Mode Tools to know how to install and configure laptop-mode-tools.

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

Or, add the desired governor(s) to the MODULES array in Template:Filename and reboot.

MODULES=(acpi-cpufreq cpufreq_ondemandcpufreq_powersave)

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

Note that the previous command only sets the governor for the first processor. If you have a multicore or multiprocessor system, use the -c flag to set the governor for a specific core. For example, to set the governor for the fourth core (core numbers start from zero):

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/cpufreq/ondemand/up_threshold

The value returned should be 80, 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 80% utilization. The can be changed, for example:

echo "15" > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold

Note: The minimum value one can enter must be above the one in down_threshold; entering a value under that results in the error, "bash: echo: write error: Invalid argument"

Note: Appending the echo line to the Template:Filename will allow it to "survive" a reboot.

Note: For an unknown reason putting the echo in Template:Filename was not working for me. Something was probably resetting it afterwards. I had to find a workaround :

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:

Daemon

cpufrequtils also includes a daemon which allows users to set the desired scaling governor and min/max clock speeds for all processor cores at boot-time, without the need for additional tools such as kpowersave.

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:

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:

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.

Sometimes the deamon may not throttle to the maximum frequence but one step below. This can be solved by setting max_freq value slightly higher than the real maximum. For example, if frequence range of the CPU is from 2.00GHz to 3.00GHz, setting max_freq to 3.01GHz can be a good idea.

Some cpu/bios configurations may have difficulties to scale to the maximum frequencies or scale to highter frequencies at all. Sadly there is only a workaround right now. Add "processor.ignore_ppc=1" to your kernel boot line and/or edit the value in /sys/module/processor/parameters/ignore_ppcfrom 0 to 1.