Power management/Processor

From Gentoo Wiki
Jump to:navigation Jump to:search
This page contains changes which are not marked for translation.
Other languages:

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, if available, are enabled:

  • "Processor C1E support"
  • "Enhanced Intel SpeedStep (EIST)"
  • "AMD Cool'n'Quiet (C&Q)"
  • "AMD PowerNow!"

Kernel

Activate the following kernel options:

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

A CPUFreq governor is needed, which is responsible for choosing the target 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. For Intel core processors, this should be selected as default. [1] [2]
'powersave' governor cpufreq_powersave Sets the frequency statically to the lowest available CPU frequency. Can't be set as default.
'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 immediately changes frequency based on the CPU utilization. For processors other than Intel core, this should be selected as default.
'conservative' cpufreq governor cpufreq_conservative Similar to ondemand. The frequency is gracefully increased and decreased rather than jumping to 100% when speed is required.
'schedutil' cpufreq policy governor cpufreq_schedutil Aimed at driving the frequency changes by kernel scheduler[3]
Tip
Name of the active CPUFreq governor is available in: /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
CPU frequency scaling drivers
Option Module / Kernel symbol Supported Processors Note
Intel P state control intel_pstate (CONFIG_X86_INTEL_PSTATE) Newer (Sandy Bridge+) Intel Core 'intel_cpufreq' mode of the 'intel_pstate' driver enabled for Intel Core/Xeon processors lacking HWP (hwp CPU flag) support.[4]
ACPI Processor P-States driver acpi-cpufreq (CONFIG_X86_ACPI_CPUFREQ) AMD EPYC/Ryzen, older Intel Core (pre-Sandy Bridge)/Xeon, AMD Opteron/Phenom, Intel Atom, Intel Pentium M Acts as a generic CPUFreq driver
AMD Processor P-State driver (kernel v5.17 and above)[5] amd-pstate (X86_AMD_PSTATE). AMD Zen 2 and Zen 3 CPU/APUs Supports the standard CPUFreq governors outlined in the section above (schedutil, ondemand, etc.)
AMD Opteron/Athlon64 PowerNow! powernow-k8 (CONFIG_X86_POWERNOW_K8) AMD Opteron/Athlon 64, AMD Turion 64 Supports older AMD K8-based processors
Intel Enhanced SpeedStep (deprecated) speedstep-centrino (CONFIG_X86_SPEEDSTEP_CENTRINO) Intel Pentium M (Centrino)/Xeon Deprecated, use ACPI Processor P-States driver instead
Intel Pentium 4 clock modulation p4-clockmod (CONFIG_X86_P4_CLOCKMOD) Intel Pentium 4/Xeon Causes severe slowdowns and noticeable latency
Processor Clocking Control interface driver pcc-cpufreq (CONFIG_X86_PCC_CPUFREQ) Adds support for the Processor Clocking Control (PCC) interface.
Tip
Name of the active CPUFreq driver is available in: /sys/devices/system/cpu/cpu*/cpufreq/scaling_driver

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. Details about the available tickless modes can be found in the kernel documentation.

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 for power saving features:

KERNEL Enabling tick optimizing functions in the kernel (CONFIG_NO_HZ_IDLE, CONFIG_HIGH_RES_TIMERS, CONFIG_HPET)
General setup  --->
   Timers subsystem  --->
      [*] Idle dynticks system (tickless idle)
      [*] High Resolution Timer Support
Device Drivers  --->
   Character devices  --->
      [*] HPET Timer Support

PowerTOP

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

When it is run, it sorts the running processes in order of how often they cause the processor to wake up. For details on installation, configuration and usage see the separate PowerTOP article.

Manual governor change

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

root #echo ondemand | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor

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

Hprofile

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.

See also

External resources

References

  1. Dominik Brodowski. Intel P-State driver, CPU frequency and voltage scaling code in the Linux(TM) kernel. Retrieved 12 June 2016.
  2. Michael Larabel. Linux's "Ondemand" Governor Is No Longer Fit. Retrieved 15 October 2016.
  3. Improvements in CPU frequency management, LWN.net, Neil Brown, 6 April 2016. Retrieved 12 January 2022.
  4. intel_pstate CPU Performance Scaling Driver, kernel.org, Rafael J. Wysocki. Retrieved 12 January 2022.
  5. https://www.kernel.org/doc/html/latest/admin-guide/pm/amd-pstate.html