Power management/Processor

From Gentoo Wiki
Jump to: navigation, search
Other languages:
English

This article describes the setup of power management for processors.

CPU frequency scaling

CPU frequency scaling is a technique whereby the frequency of a processor can be automatically adjusted "on the fly" to conserve power and to reduce the amount of heat generated by the chip.

Installation

BIOS

Some functions can be enabled or disabled in the BIOS. Check that the following are enabled:

  • "Processor C1E support"
  • "Enhanced Speedstep (EIST)"

Kernel

Activate the following kernel options:

KERNEL Enabling CPU power management options
Power management and ACPI options  --->
     [*] ACPI (Advanced Configuration and Power Interface) Support  --->
         <*>   Processor
     CPU Frequency scaling  --->
         [*] CPU Frequency scaling
             Default CPUFreq governor (ondemand)  --->
                 Select a default governor; see below table
                 Default is:
                 ondemand
             x86 CPU frequency scaling drivers  --->
                 Select a driver, see below table

A governor is needed, which is responsible for changing the frequency based on its profile:

Default CPUFreq governor
Option Module Supported Processors Note
'performance' governor cpufreq_performance Sets the frequency statically to the highest available CPU frequency.
'powersave' governor cpufreq_powersave Sets the frequency statically to the lowest available CPU frequency. Can't be set as default governor
'userspace' governor for userspace frequency scaling cpufreq_userspace To set the CPU frequency manually or when a userspace program shall be able to set the CPU dynamically.
'ondemand' cpufreq policy governor cpufreq_ondemand Does a periodic polling and changes frequency based on the CPU utilization. recommend
'conservative' cpufreq governor cpufreq_conservative Similar to ondemand. The frequency is gracefully increased and decreased rather than jumping to 100% when speed is required.
x86 CPU frequency scaling drivers
Option Module Supported Processors Note
Processor Clocking Control interface driver pcc-cpufreq
ACPI Processor P-States driver acpi-cpufreq Intel Core, Intel Core 2, Intel Atom, Intel Pentium M
AMD Opteron/Athlon64 PowerNow! powernow-k8 AMD Opteron, AMD Athlon 64, AMD Turion 64
Intel Enhanced SpeedStep (deprecated) speedstep_centrino Intel Pentium M (Centrino), Intel Xeon Deprecate, use ACPI Processor P-States driver instead.
Intel Pentium 4 clock modulation p4-clockmod Intel Pentium 4, Intel XEON Causes severe slowdowns and noticeable latencies

Ticks

The processor saves the most energy when the processor stays longer in power savings mode, so reduce the amount of ticks that wakes the processor up.

Installation

BIOS

Some functions can be enabled or disabled in the BIOS. Check that the following are enabled:

  • "HPET"
  • "Multimedia timer"

Kernel

Activate the following kernel options:

KERNEL Enabling tick optimizing functions in the kernel
Processor type and features  --->
   [*] Tickless System (Dynamic Ticks)
   [*] High Resolution Timer Support
   [*] HPET Timer Support
Note
These options now appear to be under "General setup" -> "Timers subsystem".

PowerTOP

PowerTOP is a utility designed to measure, explain and minimize a computer's electrical power consumption.

Installation

Kernel

Please refer to the Kernel section in the PowerTOP article for more information.

KERNEL Enabling powertop functions
Power management and ACPI options  --->
   [*] Power Management Debug Support
   [*]   Extra PM attributes in sysfs for low-level debugging/testing
Kernel hacking  --->
   [*] Kernel debugging
   [*] Collect kernel timers statistics

Software

Install sys-power/powertop:


USE flag (what is that?) Default Recommended Description
unicode Yes Add support for Unicode
X No Add support for X11
root #emerge --ask sys-power/powertop
Important
For kernel 3.3 onwards, one will need to enable the following kernel options (maybe incomplete list) to get proper support. Some of the following config are already enabled in the previous graphical kernel configuration. One can use the following to quickly check if the required options are set or not. The last two options are not mandatory.
FILE /usr/src/linux/.config
CONFIG_NO_HZ
CONFIG_HIGH_RES_TIMERS
CONFIG_HPET_TIMER
CONFIG_CPU_FREQ_GOV_ONDEMAND
CONFIG_USB_SUSPEND
CONFIG_SND_AC97_POWER_SAVE
CONFIG_TIMER_STATS
CONFIG_PERF_EVENTS
CONFIG_PERF_COUNTERS
CONFIG_TRACEPOINTS
CONFIG_TRACING
# These do not seem to be mandatory:
CONFIG_EVENT_POWER_TRACING_DEPRECATED
CONFIG_ACPI_PROCFS_POWER

Usage

When powertop is ran, it sorts the running processes in order of how often they cause the processor to wake up.

Hprofile

It is possible to change the active CPU governer using a simple command:

root #for c in $(ls -d /sys/devices/system/cpu/cpu[0-9]*); do echo ondemand >$c/cpufreq/scaling_governor; done

Read /etc/local.d/README to learn how to execute this command on startup.

Applications such as sys-power/cpupower do little more than the above but with some interface on top of it. However, having to run certain commands as root depending on the system usage is not efficient for most users. It is better to automate some of the decisions of governing CPU frequency. For instance, when not wired to AC power, most users would like to have the system in a power saving mode.

This is where Hprofile comes into play. Please refer to its article for more information and configuration.