amd_energy.rst 3.6 KB

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