CPU frequency scaling

From ArchWiki
Jump to navigation Jump to search


Template:I18n links start Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n links end

Merge-arrows-2.pngThis article or section is a candidate for merging with Cpufrequtils.Merge-arrows-2.png

Notes: Talk:Cpufrequtils (Discuss in Talk:CPU frequency scaling#)

CPU Frequency Scaling is a technology primarily for notebooks that enables the OS to scale the CPU speed to system and/or power use. For instance, slowing down the CPU when a notebook is on battery power, saves battery life. Intel calls this technology SpeedStep.The equivalent AMD technology is called PowerNow! or Cool'n'Quiet.


Steps

1. Install cpufrequtils

# pacman -S cpufrequtils

2. Load kernel module

Intel:

# modprobe acpi_cpufreq

If you have an older Intel CPU and the command returns with:

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

try

# modprobe p4-clockmod
# modprobe speedstep-ich

for Pentium 4 or Pentium III-M and earlier, instead.

AMD:

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

3. Load scaling governor(s)

# modprobe cpufreq_ondemand
# modprobe cpufreq_powersave

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

MODULES=( acpi_cpufreq cpufreq_ondemand cpufreq_powersave vboxdrv fuse fglrx iwl3945 ... )

or, if you have an AMD:

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

4. Edit /etc/conf.d/cpufreq as root, selecting the desired governor:

#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 min_freq and max_freq lines can be commented out, as the kernel driver should see your values automatically.

The min_freq and max_freq of the CPU can be found out by:

# cpufreq-info

or

# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies

Just check the output.

5. Start the cpufreq daemon:

# /etc/rc.d/cpufreq start

Add cpufreq to the DAEMONS list in /etc/rc.conf. For example:

DAEMONS=( cpufreq )



6. (Optional) Install and setup a GUI tool in your desktop environment. For KDE there is KLaptop and KPowersave. The latter is available via AUR and has more features. The devel-version is recommended, as it no longer depends on powersave.

Performance problems

Some CPUs do not have good performance with the default settings of the ondemand governor, which sometimes results in poor performance, like flash videos not playing smoothly or stuttering animations on window manager tasks. 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.

You can see the current (default) value of the up_threshold with the command:

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

To lower it, as root execute (35 seems to be a good value that solves most problems):

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

Some CPUs like AMD Phenom (I & II) series, Turion X2 RM-xx and ZM-xx series and Intel's Core i7 series support individual core frequency. For those make sure you apply the value on all the cores of your CPU (/cpu0/, /cpu1/ ...).

If you want the values to be changed each time Arch Linux boots, you can add those commands in your /etc/rc.local file.

Be careful as extremely low values of the up_threshold variable will negate the effects of CPU frequency scaling (lower power consumption and heat).

Other resources

cpufrequtils - info for advanced users

Trayfreq - a tray icon to control cpu frequency scaling