← Documents Documentation/hwmon/fam15h_power.rst GitHub 원문 ↗

Linux 6.18.37 · Hardware Monitoring

Kernel driver fam15h_power

AMD Family 15h·16h의 TDP 값과 누적 MSR 기반 평균 전력 계산입니다.

Source pathDocumentation/hwmon/fam15h_power.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약·해설

fam15h_power.rst:1-131

Northbridge power register와 두 시점의 accumulator·PTSC sample로 package 전력을 제공합니다.

문서 개요
항목
SourceDocumentation/hwmon/fam15h_power.rst
분량131 source lines
ProcessorAMD Family 15h·16h
기본 interval10ms

원문 분량과 핵심 범위입니다.

핵심 흐름
PCI register 확인TDP 값 계산누적 sample 수집Rollover 보정 평균

장치 동작의 기본 순서입니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
1 Kernel driver fam15h_power
2 ==========================
3
4 Supported chips:
5
6 * AMD Family 15h Processors
7
8 * AMD Family 16h Processors
9
10 Prefix: 'fam15h_power'
11
12 Addresses scanned: PCI space
13
14 Datasheets:
15
16 - BIOS and Kernel Developer's Guide (BKDG) For AMD Family 15h Processors
17 - BIOS and Kernel Developer's Guide (BKDG) For AMD Family 16h Processors
18 - AMD64 Architecture Programmer's Manual Volume 2: System Programming
19
20 Author: Andreas Herrmann <herrmann.der.user@googlemail.com>
21
22 Description
23 -----------
24
25 1) Processor TDP (Thermal design power)
26
27 Given a fixed frequency and voltage, the power consumption of a
28 processor varies based on the workload being executed. Derated power
29 is the power consumed when running a specific application. Thermal
30 design power (TDP) is an example of derated power.
31
32 This driver permits reading of registers providing power information
33 of AMD Family 15h and 16h processors via TDP algorithm.
34
35 For AMD Family 15h and 16h processors the following power values can
36 be calculated using different processor northbridge function
37 registers:
38
39 * BasePwrWatts:
40 Specifies in watts the maximum amount of power
41 consumed by the processor for NB and logic external to the core.
42
43 * ProcessorPwrWatts:
44 Specifies in watts the maximum amount of power
45 the processor can support.
46 * CurrPwrWatts:
47 Specifies in watts the current amount of power being
48 consumed by the processor.
49
50 This driver provides ProcessorPwrWatts and CurrPwrWatts:
51
52 * power1_crit (ProcessorPwrWatts)
53 * power1_input (CurrPwrWatts)
54
55 On multi-node processors the calculated value is for the entire
56 package and not for a single node. Thus the driver creates sysfs
57 attributes only for internal node0 of a multi-node processor.
58
59 2) Accumulated Power Mechanism
60
61 This driver also introduces an algorithm that should be used to
62 calculate the average power consumed by a processor during a
63 measurement interval Tm. The feature of accumulated power mechanism is
64 indicated by CPUID Fn8000_0007_EDX[12].
65
66 * Tsample:
67 compute unit power accumulator sample period
68
69 * Tref:
70 the PTSC counter period
71
72 * PTSC:
73 performance timestamp counter
74
75 * N:
76 the ratio of compute unit power accumulator sample period to the
77 PTSC period
78
79 * Jmax:
80 max compute unit accumulated power which is indicated by
81 MaxCpuSwPwrAcc MSR C001007b
82
83 * Jx/Jy:
84 compute unit accumulated power which is indicated by
85 CpuSwPwrAcc MSR C001007a
86 * Tx/Ty:
87 the value of performance timestamp counter which is indicated
88 by CU_PTSC MSR C0010280
89
90 * PwrCPUave:
91 CPU average power
92
93 i. Determine the ratio of Tsample to Tref by executing CPUID Fn8000_0007.
94
95 N = value of CPUID Fn8000_0007_ECX[CpuPwrSampleTimeRatio[15:0]].
96
97 ii. Read the full range of the cumulative energy value from the new
98 MSR MaxCpuSwPwrAcc.
99
100 Jmax = value returned.
101
102 iii. At time x, SW reads CpuSwPwrAcc MSR and samples the PTSC.
103
104 Jx = value read from CpuSwPwrAcc and Tx = value read from PTSC.
105
106 iv. At time y, SW reads CpuSwPwrAcc MSR and samples the PTSC.
107
108 Jy = value read from CpuSwPwrAcc and Ty = value read from PTSC.
109
110 v. Calculate the average power consumption for a compute unit over
111 time period (y-x). Unit of result is uWatt::
112
113 if (Jy < Jx) // Rollover has occurred
114 Jdelta = (Jy + Jmax) - Jx
115 else
116 Jdelta = Jy - Jx
117 PwrCPUave = N * Jdelta * 1000 / (Ty - Tx)
118
119 This driver provides PwrCPUave and interval(default is 10 millisecond
120 and maximum is 1 second):
121
122 * power1_average (PwrCPUave)
123 * power1_average_interval (Interval)
124
125 The power1_average_interval can be updated at /etc/sensors3.conf file
126 as below:
127
128 chip `fam15h_power-*`
129 set power1_average_interval 0.01
130
131 Then save it with "sensors -s".
132

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

AMD Family 15h·16h 지원

1-23

이 드라이버는 AMD Family 15h와 Family 16h processor를 지원하며 prefix는 `fam15h_power`입니다. 장치는 PCI space에서 검색합니다.

참조 문서는 AMD Family 15h·16h BIOS and Kernel Developer's Guide(BKDG)와 AMD64 Architecture Programmer's Manual Volume 2: System Programming입니다. 저자는 Andreas Herrmann입니다.

fam15h_power metadata
항목
ProcessorAMD Family 15h, 16h
Prefixfam15h_power
검색 공간PCI space
문서BKDG 및 AMD64 APM Volume 2

Power register 해석에 사용하는 processor family와 자료입니다.

Power driver 등록
PCI family 식별Northbridge function register 확인TDP algorithm 준비Hwmon power attribute 등록

PCI northbridge 기능에서 package power 정보를 찾습니다.

Kernel driver fam15h_power
==========================

Supported chips:

* AMD Family 15h Processors

* AMD Family 16h Processors

  Prefix: 'fam15h_power'

  Addresses scanned: PCI space

  Datasheets:

  - BIOS and Kernel Developer's Guide (BKDG) For AMD Family 15h Processors
  - BIOS and Kernel Developer's Guide (BKDG) For AMD Family 16h Processors
  - AMD64 Architecture Programmer's Manual Volume 2: System Programming

Author: Andreas Herrmann <herrmann.der.user@googlemail.com>

Description
-----------

TDP 기반 전력 값

24-58

고정된 frequency와 voltage에서도 processor 소비 전력은 실행 workload에 따라 달라집니다. 특정 application을 실행할 때 소비하는 전력이 derated power이며 thermal design power(TDP)가 그 예입니다. 이 드라이버는 TDP algorithm을 통해 AMD Family 15h·16h power register를 읽습니다.

서로 다른 processor northbridge function register로 `BasePwrWatts`, `ProcessorPwrWatts`, `CurrPwrWatts`를 계산할 수 있습니다. `BasePwrWatts`는 core 외부의 NB와 logic이 소비하는 최대 전력, `ProcessorPwrWatts`는 processor가 지원할 수 있는 최대 전력, `CurrPwrWatts`는 현재 processor 소비 전력이며 모두 watt 단위입니다.

드라이버는 `ProcessorPwrWatts`를 `power1_crit`, `CurrPwrWatts`를 `power1_input`으로 제공합니다. Multi-node processor에서 계산값은 단일 node가 아니라 전체 package 값이므로 내부 node0에만 sysfs attribute를 만듭니다.

TDP power 값
의미Sysfs
BasePwrWattsNB·core 외부 logic 최대 소비직접 미노출
ProcessorPwrWattsProcessor 지원 최대 전력power1_crit
CurrPwrWatts현재 processor 소비 전력power1_input
Multi-node전체 package 값내부 node0에만 게시

Register 기반 값과 hwmon attribute 대응입니다.

TDP 값 게시
Function register 읽기TDP algorithm 적용ProcessorPwrWatts 계산CurrPwrWatts 계산Node0 sysfs에 게시

Northbridge register를 package 단위 hwmon 값으로 변환합니다.


1) Processor TDP (Thermal design power)

Given a fixed frequency and voltage, the power consumption of a
processor varies based on the workload being executed. Derated power
is the power consumed when running a specific application. Thermal
design power (TDP) is an example of derated power.

This driver permits reading of registers providing power information
of AMD Family 15h and 16h processors via TDP algorithm.

For AMD Family 15h and 16h processors the following power values can
be calculated using different processor northbridge function
registers:

* BasePwrWatts:
    Specifies in watts the maximum amount of power
    consumed by the processor for NB and logic external to the core.

* ProcessorPwrWatts:
    Specifies in watts the maximum amount of power
    the processor can support.
* CurrPwrWatts:
    Specifies in watts the current amount of power being
    consumed by the processor.

This driver provides ProcessorPwrWatts and CurrPwrWatts:

* power1_crit (ProcessorPwrWatts)
* power1_input (CurrPwrWatts)

On multi-node processors the calculated value is for the entire
package and not for a single node. Thus the driver creates sysfs
attributes only for internal node0 of a multi-node processor.

Accumulated Power Mechanism 용어

59-92

드라이버는 측정 구간 `Tm` 동안 processor가 소비한 평균 전력을 계산하는 accumulated power mechanism algorithm도 제공합니다. 이 기능의 존재는 `CPUID Fn8000_0007_EDX[12]`로 확인합니다.

`Tsample`은 compute unit power accumulator sample period, `Tref`는 PTSC counter period, `PTSC`는 performance timestamp counter입니다. `N`은 Tsample과 PTSC period의 비율입니다.

`Jmax`는 `MaxCpuSwPwrAcc MSR C001007b`가 나타내는 compute unit accumulated power 최댓값입니다. `Jx`·`Jy`는 `CpuSwPwrAcc MSR C001007a`에서 읽는 두 시점의 누적 전력이고, `Tx`·`Ty`는 `CU_PTSC MSR C0010280`에서 읽는 두 시점의 performance timestamp counter입니다. `PwrCPUave`는 CPU average power입니다.

누적 전력 기호
기호의미출처
TsampleAccumulator sample periodCompute unit
TrefPTSC counter periodPTSC
NTsample/Tref 비율CPUID Fn8000_0007
Jmax누적 전력 최댓값MSR C001007b
Jx, Jy시점 x·y 누적 전력MSR C001007a
Tx, Ty시점 x·y timestampMSR C0010280
PwrCPUaveCPU 평균 전력계산 결과

평균 전력 계산에 쓰는 register와 시간 값입니다.

평균 전력 표본
CPUID로 기능 확인N과 Jmax 읽기시점 x에서 Jx·Tx sample시점 y에서 Jy·Ty sampleRollover 보정 후 평균 계산

두 시점의 accumulator와 PTSC 차이를 함께 사용합니다.

2) Accumulated Power Mechanism

This driver also introduces an algorithm that should be used to
calculate the average power consumed by a processor during a
measurement interval Tm. The feature of accumulated power mechanism is
indicated by CPUID Fn8000_0007_EDX[12].

* Tsample:
        compute unit power accumulator sample period

* Tref:
        the PTSC counter period

* PTSC:
        performance timestamp counter

* N:
        the ratio of compute unit power accumulator sample period to the
        PTSC period

* Jmax:
        max compute unit accumulated power which is indicated by
        MaxCpuSwPwrAcc MSR C001007b

* Jx/Jy:
        compute unit accumulated power which is indicated by
        CpuSwPwrAcc MSR C001007a
* Tx/Ty:
        the value of performance timestamp counter which is indicated
        by CU_PTSC MSR C0010280

* PwrCPUave:
        CPU average power

평균 전력 계산식

93-118

먼저 `CPUID Fn8000_0007`을 실행해 `Tsample/Tref` 비율을 정합니다. `N`은 `CPUID Fn8000_0007_ECX[CpuPwrSampleTimeRatio[15:0]]`의 값입니다. 이어 `MaxCpuSwPwrAcc`에서 누적 energy의 전체 범위를 읽어 `Jmax`로 둡니다.

시점 x에서 software가 `CpuSwPwrAcc`와 PTSC를 읽어 `Jx`, `Tx`를 얻고, 시점 y에서 같은 register를 읽어 `Jy`, `Ty`를 얻습니다.

`Jy < Jx`이면 accumulator rollover가 발생했으므로 `Jdelta = (Jy + Jmax) - Jx`, 그렇지 않으면 `Jdelta = Jy - Jx`입니다. Compute unit의 x~y 평균 전력은 micro-watt 단위로 `PwrCPUave = N * Jdelta * 1000 / (Ty - Tx)`입니다.

PwrCPUave 계산
조건Jdelta평균 전력
Jy < Jx(Jy + Jmax) - JxN * Jdelta * 1000 / (Ty - Tx)
Jy >= JxJy - JxN * Jdelta * 1000 / (Ty - Tx)
결과 단위-uWatt

Rollover 여부에 따라 energy delta만 달라집니다.

Accumulated power algorithm
N·Jmax 결정Jx·Tx 읽기Jy·Ty 읽기Rollover 여부 판정PwrCPUave 계산

CPUID 비율과 두 MSR sample로 구간 평균을 구합니다.

i. Determine the ratio of Tsample to Tref by executing CPUID Fn8000_0007.

        N = value of CPUID Fn8000_0007_ECX[CpuPwrSampleTimeRatio[15:0]].

ii. Read the full range of the cumulative energy value from the new
    MSR MaxCpuSwPwrAcc.

        Jmax = value returned.

iii. At time x, SW reads CpuSwPwrAcc MSR and samples the PTSC.

        Jx = value read from CpuSwPwrAcc and Tx = value read from PTSC.

iv. At time y, SW reads CpuSwPwrAcc MSR and samples the PTSC.

        Jy = value read from CpuSwPwrAcc and Ty = value read from PTSC.

v. Calculate the average power consumption for a compute unit over
   time period (y-x). Unit of result is uWatt::

        if (Jy < Jx) // Rollover has occurred
                Jdelta = (Jy + Jmax) - Jx
        else
                Jdelta = Jy - Jx
        PwrCPUave = N * Jdelta * 1000 / (Ty - Tx)

Average power interval 설정

119-131

드라이버는 `PwrCPUave`를 `power1_average`로, 측정 interval을 `power1_average_interval`로 제공합니다. 기본 interval은 10 millisecond이고 최댓값은 1 second입니다.

`/etc/sensors3.conf`에서 `chip `fam15h_power-*`` 항목에 `set power1_average_interval 0.01`을 넣어 interval을 갱신할 수 있습니다. 이후 `sensors -s`로 설정을 저장·적용합니다.

Average power sysfs
Attribute의미범위·예
power1_averagePwrCPUaveuWatt
power1_average_interval측정 interval기본 10ms, 최대 1s
/etc/sensors3.confPersistent 설정0.01
sensors -s설정 적용저장 후 실행

평균값과 측정 구간의 사용자 interface입니다.

Interval 변경
fam15h_power chip matchaverage_interval 값 설정sensors3.conf 저장sensors -s 실행새 interval로 평균 측정

sensors configuration을 통해 다음 평균 구간을 정합니다.

This driver provides PwrCPUave and interval(default is 10 millisecond
and maximum is 1 second):

* power1_average (PwrCPUave)
* power1_average_interval (Interval)

The power1_average_interval can be updated at /etc/sensors3.conf file
as below:

chip `fam15h_power-*`
        set power1_average_interval 0.01

Then save it with "sensors -s".