Power management/Processor
This article describes the setup of power management for prozessors.
Contents |
CPU frequency scaling
| External resources |
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 them are enabled, e.g.:
- Processor C1E support
- Enhanced Speedstep (EIST)
Kernel
You need to activate the following kernel 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 tableYou need a governor, who changes the frequency based on his profile:
| 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. |
| 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 he stays for longer in power savings modes, so you have to reduce the amount of ticks, that wakes him up.
Installation
BIOS
Some functions can be enabled or disabled in the BIOS. Check that them are enabled, e.g.:
- HPET
- Multimedia timer
Kernel
You need to activate the following kernel options:
Processor type and features ---> [*] Tickless System (Dynamic Ticks) [*] High Resolution Timer Support [*] HPET Timer Support
PowerTOP
PowerTOP is a utility designed to measure, explain and minimise a computer's electrical power consumption.
Installation
Kernel
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 | Default | Recommended | Description |
|---|---|---|---|
| unicode | Yes | Adds support for Unicode |
root # emerge --ask sys-power/powertopCONFIG_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 CONFIG_EVENT_POWER_TRACING_DEPRECATED CONFIG_ACPI_PROCFS_POWER
I used a few time sys-power/powertop-1 before and the software was pretty good at giving good advise on what power management options to set up depending on the system usage. Now, version 2 become very good in that I nearly get 10-15° less CPU temperature enabling every power management option which is almost what I can get on cold weather (~40°C) while my laptop runs almost at 50-55°C in summer (quite hot... compiling/chunking around C++ objetcs make it jump to almost 100°C! (qt-libraries, libreoffice, chromium) or simply with Wifi card on). With everything enabled, the CPU runs almost all the time (when no power hungry application is running obviously) at idle or the lowest C-state (800MHz). I could not expect better. The spot that is missing is a deamon-ish application or at least a configuration/profile file that PowerTOP will pick up at start up. Lets submit the idea to upstream.
Usage
powertop - Sorts the running processes in order how often they cause the processor to wake up.
Cpufrequtils
Install the package to get started. And do not forget to add the init service in the boot level afterwards.
root # emerge --ask sys-power/cpufrequtilsroot # rc-update add cpufrequtils bootAnd do not forget to set up the default governor that fits the machine in the configuration file.
START_OPTS="--governor ondemand"
I used sys-power/cpufrequtils and other equivalent CPU frequency utilities in the past only to remove them after a few days. The thing is... one can do just that with seting up or building the necessary modules or rather CPU governors and set up a default governor in the kernel. That should suffice for most users especially with ondemand governor.
Hprofile
When one need to change CPU governor, on can just use a simple command as the following which nullify the usage of cpufrequtils or other CPU governor and frequency utilities.
root # for c in $(ls -d /sys/devices/system/cpu/cpu[0-9]*); do
echo ondemand >$c/cpufreq/scaling_governor; doneHowever, that kind of commands need a little automation... think if you're using a laptop and want it to be a little dynamic in power saving mode, you will surely want a power saving profile if the laptop is not wired to AC power. This is where Hprofile comes into play, follow reading in that article for more information.