• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1.. SPDX-License-Identifier: GPL-2.0
2
3Kernel driver amd_energy
4==========================
5
6Supported chips:
7
8* AMD Family 17h Processors
9
10  Prefix: 'amd_energy'
11
12  Addresses used:  RAPL MSRs
13
14  Datasheets:
15
16  - Processor Programming Reference (PPR) for AMD Family 17h Model 01h, Revision B1 Processors
17
18	https://developer.amd.com/wp-content/resources/55570-B1_PUB.zip
19
20  - Preliminary Processor Programming Reference (PPR) for AMD Family 17h Model 31h, Revision B0 Processors
21
22	https://developer.amd.com/wp-content/resources/56176_ppr_Family_17h_Model_71h_B0_pub_Rev_3.06.zip
23
24Author: Naveen Krishna Chatradhi <nchatrad@amd.com>
25
26Description
27-----------
28
29The Energy driver exposes the energy counters that are
30reported via the Running Average Power Limit (RAPL)
31Model-specific Registers (MSRs) via the hardware monitor
32(HWMON) sysfs interface.
33
341. Power, Energy and Time Units
35   MSR_RAPL_POWER_UNIT/ C001_0299:
36   shared with all cores in the socket
37
382. Energy consumed by each Core
39   MSR_CORE_ENERGY_STATUS/ C001_029A:
40   32-bitRO, Accumulator, core-level power reporting
41
423. Energy consumed by Socket
43   MSR_PACKAGE_ENERGY_STATUS/ C001_029B:
44   32-bitRO, Accumulator, socket-level power reporting,
45   shared with all cores in socket
46
47These registers are updated every 1ms and cleared on
48reset of the system.
49
50Note: If SMT is enabled, Linux enumerates all threads as cpus.
51Since, the energy status registers are accessed at core level,
52reading those registers from the sibling threads would result
53in duplicate values. Hence, energy counter entries are not
54populated for the siblings.
55
56Energy Caluclation
57------------------
58
59Energy information (in Joules) is based on the multiplier,
601/2^ESU; where ESU is an unsigned integer read from
61MSR_RAPL_POWER_UNIT register. Default value is 10000b,
62indicating energy status unit is 15.3 micro-Joules increment.
63
64Reported values are scaled as per the formula
65
66scaled value = ((1/2^ESU) * (Raw value) * 1000000UL) in uJoules
67
68Users calculate power for a given domain by calculating
69	dEnergy/dTime for that domain.
70
71Energy accumulation
72--------------------------
73
74Current, Socket energy status register is 32bit, assuming a 240W
752P system, the register would wrap around in
76
77	2^32*15.3 e-6/240 * 2 = 547.60833024 secs to wrap(~9 mins)
78
79The Core energy register may wrap around after several days.
80
81To improve the wrap around time, a kernel thread is implemented
82to accumulate the socket energy counters and one core energy counter
83per run to a respective 64-bit counter. The kernel thread starts
84running during probe, wakes up every 100secs and stops running
85when driver is removed.
86
87Frequency of the accumulator thread is set during the probe
88based on the chosen energy unit resolution. For example
89A. fine grain (1.625 micro J)
90B. course grain (0.125 milli J)
91
92A socket and core energy read would return the current register
93value added to the respective energy accumulator.
94
95Sysfs attributes
96----------------
97
98=============== ========  =====================================
99Attribute	Label	  Description
100===============	========  =====================================
101
102* For index N between [1] and [nr_cpus]
103
104===============	========  ======================================
105energy[N]_input EcoreX	  Core Energy   X = [0] to [nr_cpus - 1]
106			  Measured input core energy
107===============	========  ======================================
108
109* For N between [nr_cpus] and [nr_cpus + nr_socks]
110
111===============	========  ======================================
112energy[N]_input EsocketX  Socket Energy X = [0] to [nr_socks -1]
113			  Measured input socket energy
114=============== ========  ======================================
115