Power management/Processor/ko
CPU 주파수 조절
CPU 주파수 조절은 "동작중" 전원을 절약하고 칩에서 발생하는 열의 양을 줄이려는 목적으로 자동으로 조절할 수 있는 주파수를 다루는 기술입니다.
The ACPI specification describes the scaling mechanism as performance states - P-states or Processor Performance States.[1] The state labeled as P0 is used for the processor's highest possible frequency and P1-Pn states are used for lower frequencies.
Lower processor frequency leads to lower number of instruction processed over a unit of time. This means finding a balance between frequency and performance is necessary.
The kernel CPUFreq subsystem[2] is responsible for handling the frequency scaling. This subsystem provides two basic means of changing the scaling behavior:
- Scaling Governors - provide different approaches to estimate the desired processor frequency using different scaling algorithms.
- Scaling Drivers - provide an interface between scaling governors and the specific hardware. Scaling driver can read/write hardware-specific values on behalf of the governor.
The CPUFreq subsystem exposes multiple sysfs interfaces. The most useful is created per-processor /sys/devices/system/cpu/cpu*/cpufreq/. This directory contains various files, like:
- cpuinfo_cur_freq - current frequency in KHz as reported by the processor.
- cpuinfo_min_freq - minimal possible frequency in KHz as reported by the processor.
- cpuinfo_max_freq - maximal possible frequency in KHz as reported by the processor.
- scaling_governor - currently used scaling governor. It can be changed by writing to this file.
- scaling_driver - currently used scaling driver. It can be changed by writing to this file.
- scaling_min_freq - minimal processor frequency in KHz to be used by the governor. It can be set by writing to this file.
- scaling_max_freq - maximum processor frequency in KHz to be used by the governor. It can be set by writing to this file.
설치
BIOS
일부 기능은 BIOS에서 켜고 끌 수 있습니다. 다음 기능을 켰는지 확인하십시오:
- "Processor C1E support"
- "Enhanced Speedstep (EIST)"
커널
다음 커널 옵션을 활성화하십시오:
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
*** CPU frequency scaling drivers ***
Select a driver; see below table
이 프로파일에 기반하여 주파수를 바꾸는 역할을 담당하는 정책 설정이 필요합니다:
옵션 | 모듈 | 지원 프로세서 | 참고 |
---|---|---|---|
'performance' 정책 | cpufreq_performance | CPU 주파수를 최대한 높게 설정합니다. | 인텔 코어 프로세서에서는, 이 옵션을 기본으로 설정해야합니다. [3] |
'powersave' 정책 | cpufreq_powersave | CPU 주파수를 최대한 낮출 수 있는 만큼 낮춰 고정 설정합니다. | 기본 정책으로 설정할 수 없음 |
사용자 영역 주파수 제어용 'userspace' 정책 | cpufreq_userspace | CPU 주파수를 직접 설정하려 하거나 사용자 프로그램에서 CPU 주파수를 동적으로 설정할 수 있게 합니다. | |
'ondemand' cpufreq 정책 | cpufreq_ondemand | CPU 가용성을 기반으로 주기적 폴링을 수행하거나 주파수를 바꿉니다. | 인텔 코어 프로세서 외의 프로세서에는 이 옵션을 기본으로 설정해야합니다. |
'conservative' cpufreq 정책 | cpufreq_conservative | ondemand와 비슷합니다. 속도가 필요할 때는 주파수를 100% 수준으로 설정하기보단 점진적으로 올리거나 줄입니다. |
Name of the active CPUFreq governor is available in: /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
Behavior of active governor can be further configured via tunables exposed as sysfs interface. For more details see the dedicated documentation. Commonly used sysfs tunables include:
- schedutil - /sys/devices/system/cpu/cpufreq/schedutil/rate_limit_us sets minimal interval in μs between consecutive governor runs.
- ondemand - /sys/devices/system/cpu/cpufreq/ondemand/sampling_rate sets the interval in μs between consecutive load sampling runs.
- conservative - /sys/devices/system/cpu/cpufreq/conservative/freq_step sets the maximal frequency change step as % of scaling_max_freq.
옵션 | 모듈 | 지원 프로세서 | 참고 |
---|---|---|---|
인텔 P-state 제어 | intel_pstate | (샌디 브릿지 이상의) 최신 인텔코어 | |
프로세서 클록 제어 인터페이스 드라이버 | pcc-cpufreq | ||
ACPI 프로세서 P-States 드라이버 | acpi-cpufreq | 이전 Intel Core, Intel Atom, Intel Pentium M | |
AMD 옵테론/Athlon64 PowerNow! | powernow-k8 | AMD Opteron, AMD Athlon 64, AMD Turion 64 | |
Intel 고급 SpeedStep (오래된 기능) | speedstep-centrino | Intel Pentium M (Centrino), Intel Xeon | 오래된 기능이므로, 대신 ACPI Processor P-States driver 를 사용하십시오. |
Intel Pentium 4 클록 변조 | p4-clockmod | Intel Pentium 4, Intel XEON | 상당히 느려지며 눈에 띄는 레이턴시 증가 현상이 일어납니다. |
Availability of drivers depend on the processor architecture.
Name of the active CPUFreq driver is available in: /sys/devices/system/cpu/cpu*/cpufreq/scaling_driver
Specific CPU scaling drivers settings
Intel P-state
This driver implements internal scaling governors (roughly similar to CPUFreq's powersave and performance) and works based on the processor load. It is intended for recent Intel Core series of processors (based on the Sandy Bridge microarchitecture or newer).
This driver works in either active mode (intel_pstate), for processors featuring Hardware P-States (HWP), or passive mode (intel_cpufreq). The passive mode concerns the processors not supporting HWP which are generations prior the Skylake microarchitecture - no hwp
CPU flag is present.
In the active mode the processor autonomously sets the frequency based on provided CPUFreq parameters. This passes the control of frequency scaling to the processor itself. On the other hand, in the passive mode the driver behaves similarly to the generic acpi-cpufreq driver - it collaborates with the regular scaling governors. Although, it can use the full range of frequency steps.[4]
In the active mode case, the userspace, ondemand, and conservative scaling governors are unnecessary. The performance governor should be selected as the default. [5]
Power management and ACPI options --->
[*] CPU Frequency scaling --->
Default CPUFreq governor (performance) --->
-*- 'performance' governor
<*> Intel P state control
There is a sysfs interface exposed by the driver. Its root is located at the /sys/devices/system/cpu/intel_pstate/ directory. There are files like:
- no_turbo - disables the Intel Turbo Boost feature (1 means disabled and 0 means enabled). The state can be changed by writing to this file.
- status - displays the status of the driver. Values are either - off, passive, or active.
AMD P-State
This driver is available in kernel v5.17 or newer[6]. It aims to provide a more effective alternative to the generic acpi-cpufreq driver. It is based on Collaborative Processor Performance Control (CPPC)[7] to provide fine grained frequency steps. This was motivated by acpi-cpufreq providing only 3 frequency control options, and the lowest frequency is typically higher than what is made available when using amd-pstate thus being less effective than it might otherwise be as a way to maximize battery life.
It is intended for AMD Ryzen/EPYC processors based on the Zen 2 or newer microarchitecture. In case of hardware support and configuration mismatch the scaling driver gets set to the acpi-cpufreq as a fallback.
To verify the currently used driver did not fall back to acpi-cpufreq read: /sys/devices/system/cpu/cpu0/cpufreq/scaling_driver.
In order to use this driver, "CPPC", "ACPI CPPC", or similar BIOS setting must be set to enabled or auto.
Power management and ACPI options --->
[*] CPU Frequency scaling --->
Default CPUFreq governor (performance) --->
-*- 'performance' governor
[*] AMD Processor P-State driver
<M> selftest for AMD Processor P-State driver
There is a sysfs interface exposed by the driver. Its root is located at the /sys/devices/system/cpu/amd_pstate/ directory. There are files like:
- status - displays the status of the driver. Values are either - active, passive, guided, or disable.
When the currently used driver falls back to the acpi-cpufreq driver the following kernel command-line parameters can fix loading the amd-pstate driver:
- Zen 2 processors: Add
amd_pstate.shared_mem=1
to enable amd-pstate using its shared memory implementation.[8] - Zen 3 or newer processors: Add
amd-pstate=passive
. Zen 3 or newer also supports CPPC.[7]
Kernel 6.3 further developed available AMD P-State options in the form of Energy Preference Performance (EPP) modes.[9] This new driver is referred as amd_pstate_epp. It allows new combinations of drivers and governors such as "amd_pstate_epp powersave performance" or "amd_pstate_epp performance performance". Some benchmarks are available.
For further details on the AMD P-state driver see the documentation available upstream.
Manual governor/driver change
다음의 간단한 명령을 통해 활성 CPU 정책을 바꿀 수 있습니다:
root #
for c in $(ls -d /sys/devices/system/cpu/cpu[0-9]*); do
echo ondemand >$c/cpufreq/scaling_governor; done
시스템 시작시 실행하는 방법을 알아보려면 /etc/local.d/README 문서를 읽어보십시오.
Set governor at boot time
It is possible to set the default governor via cpufreq.default_governor kernel command-line parameter.
This parameter requires kernel v5.9+.[10]
클록 신호
프로세서가 전원 절약 상태에서 오래 머물러 있을 때 대부분의 전력 사용량을 절약하며, 프로세서를 동작 상태로 복귀할 때 사용하는 클록 신호 수를 최대한 줄입니다.
설치
BIOS
일부 기능은 BIOS에서 켜거나 끌 수 있습니다. 다음 기능을 켰는지 확인하십시오:
- "HPET"
- "Multimedia timer"
커널
다음 커널 옵션을 활성화하십시오:
Processor type and features --->
[*] Tickless System (Dynamic Ticks)
[*] High Resolution Timer Support
[*] HPET Timer Support
CPU Idle
Modern multi-core processors are often not fully loaded which brings an opportunity to suspend the unused parts and save power. The hardware transitions the unused parts to idle states. The kernel then does not schedule regular tasks to the idle parts but only special idle tasks.
The ACPI specification describes those idle states as C-states or Processor Power States. [11] There are usually multiple C-states implemented. Starting from the C0 state for a regularly running processor to C1, C2, and deeper idle states. The deeper the idle state, greater power saving but also a longer transition back to the running state.
The kernel CPUIdle subsystem[12] is responsible for handling the idle state management. Similarly to CPUFreq, this subsystem provides two basic means of idle state management - governor and driver. The governor attempts to predict the optimal C-state and driver to perform the operation on the hardware.
The CPUIdle subsystem exposes a sysfs interface. It is available at /sys/devices/system/cpu/cpuidle/. This directory contains various files, like:
- current_governor - currently used idle governor. It can be changed by writing to this file.
- available_governors - list of available idle governors.
- current_driver - currently used idle driver information.
Installation
BIOS
Check that the following settings are enabled in BIOS:
- "C-States"
- "ACPI C states"
Kernel
Name | Module / Kernel symbol | Supported Processors | Note |
---|---|---|---|
Intel Idle Time Driver | intel_idle (CONFIG_INTEL_IDLE) | recent (Nehalem+) Intel Core[13] | Asks the processor part to enter the idle state using the MWAIT instruction. |
ACPI Idle Driver | acpi_idle (CONFIG_ACPI_PROCESSOR_IDLE) | AMD processors, old Intel processors | Generic idle driver |
Name | Module / Kernel symbol | Note |
---|---|---|
Ladder Governor | ladder (CONFIG_CPU_IDLE_GOV_LADDER) | Default governor for systems with allowed scheduler ticks in idle - CONFIG_NO_HZ_IDLE=n. |
Menu Governor | menu (CONFIG_CPU_IDLE_GOV_MENU) | Default governor for tickless systems - CONFIG_NO_HZ_IDLE=y. |
Timer events oriented (TEO) governor | TEO (CONFIG_CPU_IDLE_GOV_TEO) | Alternative governor for tickless systems - CONFIG_NO_HZ_IDLE=y. |
Tools
PowerTOP
PowerTOP은 컴퓨터의 전기 전원 소모량을 측정하고 보여주고 최소화하도록 설계한 유틸리티입니다.
이 명령을 실행하면, 프로세서를 자주 동작하는 순으로 동작중인 프로세스를 정렬하여 보여줍니다. 설정 및 활용법에 대한 자세한 내용은 별도의 PowerTOP 게시글을 확인하십시오.
cpupower
The sys-power/cpupower package provides a set of tools to comfortably manage and monitor processor powersaving features. The tools include cpupower frequency-info, cpupower frequency-set, and cpupower monitor.
Hprofile
sys-power/cpupower와 같은 프로그램은 위에서 제시한 기능보다 더 많은 기능이 있지만 일부 인터페이스가 상단에 몰려있습니다. 그러나 대부분의 사용자에게는 시스템 사용 상태에 따른 루트 권한으로의 일부 명령을 실행이 그다지 효율적이지 않습니다. 일부 CPU 주파수 정책 결정은 그냥 자동화 해두는것이 낫습니다. 예를 들자면, 교류 전원에 연결하지 않았을 때, 대부분 사용자는 전원 절약 상태로 시스템을 두고 싶어합니다.
바로 이 시점이 Hprofile 프로그램을 동작시킬 상황입니다. 더 많은 정보와 설정 방법을 알아보려면 언급한 문서(하이퍼링크)를 참고하세요.
추가 참조
- ACPI - 고급 설정 및 전원 관리 인터페이스.
외부 자료
- What exactly is a P-state? (Pt. 1) - P-state 인텔 설명 자료.
- Linux's "Ondemand" Governor Is No Longer Fit - 최근 인텔 코어 프로세서에서 ondemand 를 사용하지 말아야 할 이유를 설명.
참고 자료
- ↑ 8. Processor Configuration and Control — ACPI Specification 6.4 documentation, UEFI Forum, Inc. Retrieved 9 September 2023.
- ↑ CPU Performance Scaling, The kernel development community. Retrieved 9 September 2023.
- ↑ Dominik Brodowski. Intel P-State driver, CPU frequency and voltage scaling code in the Linux(TM) kernel. Retrieved 12 June 2016.
- ↑ intel_pstate CPU Performance Scaling Driver, The kernel development community. Retrieved 9 September 2023.
- ↑ Dominik Brodowski. Intel P-State driver, CPU frequency and voltage scaling code in the Linux(TM) kernel. Retrieved 12 June 2016.
- ↑ AMD P-State Driver To Premiere In Linux 5.17 With Aim To Deliver Better Power Efficiency, Michael Larabel. Retrieved 9 September 2023.
- ↑ 7.0 7.1 Collaborative Processor Performance Control (CPPC), The kernel development community. Retrieved 9 September 2023.
- ↑ How to enable amd-pstate?, Manjaro.org. Retrieved 9 September 2023.
- ↑ Ryzen Mobile Power/Performance With Linux 6.3's New AMD P-State EPP Driver, Michael Larabel. Retrieved 9 September 2023.
- ↑ The kernel’s command-line parameters, The kernel development community. Retrieved 9 September 2023.
- ↑ 8.1. Processor Power States — ACPI Specification 6.4 documentation, UEFI Forum, Inc. Retrieved 10 September 2023.
- ↑ CPU Idle Time Management, The kernel development community. Retrieved 10 September 2023.
- ↑ intel_idle CPU Idle Time Management Driver, The kernel development community. Retrieved 10 September 2023.