CPU frequency scaling (Italiano)

From ArchWiki
Revision as of 16:50, 8 October 2011 by Veleno77 (talk | contribs)
Jump to: navigation, search

Tango-view-refresh-red.pngThis article or section is out of date.Tango-view-refresh-red.png

Reason: please use the first argument of the template to provide a brief explanation. (Discuss in Talk:CPU frequency scaling (Italiano)#)
Warning: Questa pagina è in fase di revisione e potrebbe non essere aggiornata. Seguite per ora le istruzioni della versione inglese.

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

Local languages: Català – Dansk – English – Español – Esperanto – Hrvatski – Indonesia – Italiano – Lietuviškai – Magyar – Nederlands – Norsk Bokmål – Polski – Português – Slovenský – Česky – Ελληνικά – Български – Русский – Српски – Українська – עברית – العربية – ไทย – 日本語 – 正體中文 – 简体中文 – 한국어

External languages (all articles in these languages should be moved to the external wiki): Deutsch – Français – Română – Suomi – Svenska – Tiếng Việt – Türkçe – فارسی

cpufreq refers to the kernel infrastructure that implements CPU frequency scaling. This technology enables the operating system to scale the CPU speed up or down in order to save power. CPU frequencies can be scaled automatically depending on the system load, in response to ACPI events, or manually by userspace programs.

At a minimum, the needed kernel modules have to be loaded and then a governor has to be set. More advanced configurations might include some combination of #cpufrequtils, acpid, laptop-mode-tools, and GUI tools provided for your desktop environment.


Template:Package Official is a set of userspace utilities designed to assist with CPU frequency scaling. The package is not 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 (see #Daemon below).

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

# pacman -S cpufrequtils


Configuring CPU scaling is a 3-part process:

  1. Load appropriate CPU frequency driver
  2. Load desired scaling governor(s)
  3. Select a method to manage switching and tuning governor(s):
    • manually via /sys interface or cpufreq-set (from cpufrequtils),
    • the cpufrequtils #Daemon,
    • Laptop Mode Tools,
    • acpid events,
    • desktop enviroment tools/applets,
    • or some combination of the above.

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). Note that these modules may need related features enabled in BIOS which may be labeled as: Speedstep, Cool and Quiet, PowerNow!, or ACPI.

If you have a 64-bit processor, you will very likely want either Template:Codeline for Intel processors or Template:Codeline for AMD K8/K10 processors (Athlon 64, Opteron, and Phenom). These modules are built for both 32 and 64-bit kernels so even if you run a 32-bit kernel on your 64-bit hardware they are probably still the ones you want.

To see a full list of available drivers, run the following:

$ ls /lib/modules/$(uname -r)/kernel/drivers/cpufreq/

The following table is a partial list of available frequency drivers (Adapted from kernel source file Template:Filename).

Module Description
acpi-cpufreq CPUFreq driver which utilizes the ACPI Processor Performance States. This driver also supports Intel Enhanced Speedstep (previously supported by the depreciated speedstep-centrino module).
speedstep-ich CPUFreq driver for certain mobile Intel Pentium III (Coppermine), all mobile Intel Pentium III-M (Tualatin) and all mobile Intel Pentium 4 P4-M on systems which have an Intel ICH2, ICH3 or ICH4 southbridge.
speedstep-smi CPUFreq driver for certain mobile Intel Pentium III (Coppermine), all mobile Intel Pentium III-M (Tualatin) on systems which have an Intel 440BX/ZX/MX southbridge.
powernow-k8 CPUFreq driver for K8/K10 Athlon64/Opteron/Phenom processors.
powernow-k7 CPUFreq driver for mobile AMD K7 mobile processors.
cpufreq-nforce2 CPUFreq driver for FSB changing on nVidia nForce2 platforms. (AMD K7, Socket A)
pcc-cpufreq This driver supports Processor Clocking Control interface by Hewlett-Packard and Microsoft Corporation which is useful on some Proliant servers.
p4-clockmod CPUFreq driver for Intel Pentium 4 / XEON processors. When enabled it will lower CPU temperature by skipping clocks.
You probably want to use a Speedstep driver instead.

To load the CPU frequency driver manually:

# modprobe acpi-cpufreq

Note that if you attempt to load the wrong module you will get get an error such as

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

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

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


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 user space programs. One may load as many governors as desired (only one will be active on a CPU 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 switches between the CPU(s) available clock speeds based on system load
Similar to Template:Codeline, but the CPU(S) clock speed switches gradually through all its available frequencies based on system load
Runs the CPU(s) at minimum speed
Manually configured clock speeds by user

For Desktops and most systems, the ondemand governor can provide the best compromise between heat emission, power consumption, performance, and manageability. For Laptops or other mobile systems, the conservative governor can possibly provide significant savings in power consumption.

Load the desired governor(s) with Template:Codeline. For example:

# modprobe cpufreq_ondemand
# modprobe cpufreq_userspace

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

MODULES=(acpi-cpufreq cpufreq_ondemand cpufreq_powersave)

To see which governors have been loaded:

cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors

Manually set the governor by running the Template:Codeline command (as root). For example:

# cpufreq-set -c 0 -g ondemand

Note that the previous command only sets the governor for the first processor! Multicore or multiprocessor systems require the -c flag to set the governor for a specific core and to repeat for each remaining. Numbering starts from 0 not 1!

For a quad core chip:

# for i in 0 1 2 3; do cpufreq-set -c $i -g ondemand; done

For a dual core chip:

# for i in 0 1; do cpufreq-set -c $i -g ondemand; done

Note: These settings will not be preserved after a reboot/shutdown. See the #Daemon section below for configuring cpufreq governors at boot.

Additional options such as upper and lower frequency bounds used by the governor can optionally be set by using the -u and -d options. A processors valid frequencies can be seen by calling cpufreq-info. For example, to set the second core's upper frequency bound as 2.00Ghz and its lower bound as 1.00Ghz:

# cpufreq-set -c 1 -g ondemand -u 2.00Ghz -d 1.00Ghz

To manually set a processor to a specific frequency the userspace governor is used. For example, to set core 0 to 2.50Ghz and core 1 to 800Mhz:

# cpufreq-set -c 0 -g userspace -f 2.50Ghz
# cpufreq-set -c 1 -g userspace -f 800Mhz

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

For those who would like a GUI for setting governors or frequency there is trayfreq, a GTK+ application that sits in the system tray.

The monitoring of CPU clock in real-time is accomplished by running:

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

Improving ondemand performance

With the out-of-the-box configuration, the ondemand governor will result in a slight but measurable and noticeable loss of performance. It will not clock up the CPU when it is at lower than 95% usage, and will sample the usage at the fastest possible frequency when at full clock speeds in order to clock back down as soon as possible.

Tuning the governor for your needs can reduce the performance loss to the point where it is negligible/non-existent if you are willing to lose a lot of the power savings. If you just want to save power while idle, lowering the up_threshold to 11% and raising the sample_down_factor by an order of magnitude can accomplish this.

Tunables are available in Template:Filename once the governor is loaded and selected and can be preserved at reboot using Template:Filename.

Starting the cpufreq daemon in the background (i.e. with an '@' in Template:Filename) will likely cause Template:Filename to be processed before the cpufreq daemon has a chance to change the governor. Make sure that the cpufreq daemon script will have finished running before the tunables are set. Example:


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

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

# echo -n 15 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold
ondemand governor sampling-down-factor

sampling_down_factor is another global ondemand global tunable.

Set to 1 it makes no changes from existing behavior, but set to greater than 1 (e.g. 100) it acts as a multiplier for the scheduling interval for reevaluating load when the CPU is at its top speed due to high load. This improves performance by reducing the overhead of load evaluation and helping the CPU stay at its top speed when truly busy, rather than shifting back and forth in speed. This tunable has no effect on behavior at lower speeds/lower CPU loads.

Read the value (default: 1):

# cat /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor

Set the value:

# echo -n 10 > /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor

Tuning conservative governor

While the conservative governor switches smoothly and utilizes all of the available frequencies, users may want to tune it further. Out-of-the-box it will clock the CPU up when load reaches 75% and clock down when load drops to 20%. As with the ondemand governor, decreasing the Template:Codeline may improve performance and responsiveness.

Tunables are available in Template:Filename. Refer to the #Improving ondemand performance section for important advice regarding making this changes permanent, and potential daemon loading issues.

Changing the Template:Codeline governor's thresholds

Determine the current Template:Codeline setting by issuing the following command as root:

# cat /sys/devices/system/cpu/cpufreq/conservative/up_threshold

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

# echo -n 40 > /sys/devices/system/cpu/cpufreq/conservative/up_threshold
Note: The minimum value one can enter must be above the one in Template:Codeline; entering a value under that results in the error, "bash: echo: write error: Invalid argument"

Similarly the Template:Codeline value can be read and modified via Template:Filename. The default value should be Template:Codeline as of kernel version 3.0. This means that the Template:Codeline governor decreases the clock rate to the next lowest speed if a core falls to 20% utilization, which is a sensible default.

While the down sampling rate can also be adjusted for the Template:Codeline governor, increasing it may only help with occasional low usage CPU spikes during high usage applications, as the Template:Codeline is a much more direct control for down scaling which does not exist on the Template:Codeline governor.

Be aware that setting Template:Codeline too close to Template:Codeline may result in constant CPU switching, which might be something desirable for certain users and not for others. Setting Template:Codeline or Template:Codeline too low may result in the CPU being clocked higher than it needs sacrificing power saving for performance, and setting Template:Codeline too high may result in decreased performance, but reduced power consumption. Experiment to find the optimal values for your system and your needs.

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. A quick example is given below, however it may be worth reading full article on acpid.

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:Codeline includes a daemon which allows users to set the desired scaling governor and min/max clock speeds for all processor cores at boot-time.

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: Template:Cli

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

DAEMONS=(syslog-ng networkmanager @alsa @crond @cupsd @cpufreq)

Privilege Granting Under Gnome

Gnome has a nice applet to change the governor on the fly. To use it without the need to enter the root password, simply create Template:Filename and populate it with the following:


Where the word USER is replaced with the username of interest.

The Template:Package AUR package in the AUR contains a similar .pkla file for authorizing all users of the power group to change the governor.

Laptop Mode Tools

If you are already using or plan to use Laptop Mode Tools for other power saving solutions, then you may want to let it also manage CPU frequency scaling. To do so, you just have to insert the appropriate frequency driver to the MODULES array in Template:Filename (see #CPU frequency driver above) and then go through the Template:Filename file to define governors, frequencies and policies. You will not need to load other modules and daemons or to set up scaling governors and interaction with ACPI events. Please refer to Laptop Mode Tools for more details.


Tango-inaccurate.pngThe factual accuracy of this article or section is disputed.Tango-inaccurate.png

Reason: please use the first argument of the template to provide a brief explanation. (Discuss in Talk:CPU frequency scaling (Italiano)#)
  • 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 packets suddenly arrive at the monitored network interface that cannot be handled by the current processor speed.
  • Some CPU's 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 ondemand governor may not throttle to the maximum frequency but one step below. This can be solved by setting max_freq value slightly higher than the real maximum. For example, if frequency range of the CPU is from 2.00 GHz to 3.00 GHz, setting max_freq to 3.01 GHz can be a good idea.
  • Some CPU/BIOS configurations may have difficulties to scale to the maximum frequencies or scale to higher 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 Template:Filename from 0 to 1. (It seems to be fixed at least since kernel 3.0, for Toshiba NB-100)
  • Some combinations of ALSA drivers and sound chips may cause audio skipping as the governor changes between frequencies, switching back to a non-changing governor seems to stop the audio skipping.

La variazionde della frequenza della CPU è una tecnologia rivolta principalmente ai notebook che consente al sistema operativo di variare la velocità di funzionamento della CPU in base al sistema ed al consumo di energia. Per esempio, rallentando la CPU quando un notebook è alimentato dalla batteria, preserva la durata della batteria stessa. Intel definisce questa tecnologia SpeedStep. L'equivalente tecnologia di AMD è detta PowerNow! o Cool'n'Quiet.



1. Installare cpufrequtils

# pacman -S cpufrequtils

2.Caricare i moduli del kernel


# modprobe acpi-cpufreq

Alcune vecchie CPU potrebbero restituire un errore simile al seguente:

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

In questo caso occorre sostituire acpi-cpufreq con uno dei seguenti moduli: speedstep-centrino, p4-clockmod, speedstep-ich. È comunque da notare che speedstep-centrino è deprecato, mentre p4-clockmod supporta solo i governor performance e powersave.


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

3. Caricare i gestori della variazione

# modprobe cpufreq_ondemand
# modprobe cpufreq_powersave

Questi moduli possono essere aggiunti all'elenco MODULES all'interno di/etc/rc.conf, così da mantenere la configurazione ad ogni riavvio. Per esempio:

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

o, se si ha un processore AMD:

 MODULES=( powernow-k8 cpufreq_ondemand cpufreq_powersave vboxdrv fuse fglrx iwl3945 ... )

4. Modificare /etc/conf.d/cpufreq come root, selezionando i gestori desiderati:

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

# valid suffixes: Hz, kHz (default), MHz, GHz, THz

Nota: le linee min_freq e max_freq dovrebbero essere commentate, dato che i driver presenti nel kernel possono rilevare questi valori automaticamente. Per esserne certi, lanciare:

# cpufreq-info

e controllarne l'output.

Demone cpufreq

Opzionalmente, si può lanciare cpufreqd come demone

# /etc/rc.d/cpufreq start

Aggiungere cpufreq alla lista DAEMONS in /etc/rc.conf.


Installare e configurare un'interfaccia grafica nel proprio Ambiente Desktop. Per KDE si può scegliere tra KLaptop e KPowersave. Quest'ultimo è reperibile tramite AUR ed è più completo. La versione in sviluppo (devel-version) è raccomandata, visto che non dipende più da powersave.

Ulteriori informazioni sono disponibili alla pagina cpufrequtils.

Nota per processori MultiCore:

1. La variazione sarà applicata solo al primo core cpu0. Aggiungere queste linee al proprio /etc/rc.local per applicare la variazione ad ogni core.

  1. echo "ondemand" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
  2. echo "ondemand" > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor

...e così via fin a quando necessario, in base al numero di core.

2. Se il secondo core non segue le regole di variazione impostate dopo un "suspend to ram" (Stand by), modificare /usr/lib/hal/scripts/linux/hal-system-power-suspend-linux ed aggiungere le linee necessarie, per esempio:

# echo "ondemand">/sys/devices/system/cpu/cpu1/cpufreq/scaling_governor

prima della riga finale ("exit$RET").

Altre risorse

cpufrequtils - informazioni per utenti esperti