intel-hybrid.txt 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. Intel hybrid support
  2. --------------------
  3. Support for Intel hybrid events within perf tools.
  4. For some Intel platforms, such as AlderLake, which is hybrid platform and
  5. it consists of atom cpu and core cpu. Each cpu has dedicated event list.
  6. Part of events are available on core cpu, part of events are available
  7. on atom cpu and even part of events are available on both.
  8. Kernel exports two new cpu pmus via sysfs:
  9. /sys/devices/cpu_core
  10. /sys/devices/cpu_atom
  11. The 'cpus' files are created under the directories. For example,
  12. cat /sys/devices/cpu_core/cpus
  13. 0-15
  14. cat /sys/devices/cpu_atom/cpus
  15. 16-23
  16. It indicates cpu0-cpu15 are core cpus and cpu16-cpu23 are atom cpus.
  17. As before, use perf-list to list the symbolic event.
  18. perf list
  19. inst_retired.any
  20. [Fixed Counter: Counts the number of instructions retired. Unit: cpu_atom]
  21. inst_retired.any
  22. [Number of instructions retired. Fixed Counter - architectural event. Unit: cpu_core]
  23. The 'Unit: xxx' is added to brief description to indicate which pmu
  24. the event is belong to. Same event name but with different pmu can
  25. be supported.
  26. Enable hybrid event with a specific pmu
  27. To enable a core only event or atom only event, following syntax is supported:
  28. cpu_core/<event name>/
  29. or
  30. cpu_atom/<event name>/
  31. For example, count the 'cycles' event on core cpus.
  32. perf stat -e cpu_core/cycles/
  33. Create two events for one hardware event automatically
  34. When creating one event and the event is available on both atom and core,
  35. two events are created automatically. One is for atom, the other is for
  36. core. Most of hardware events and cache events are available on both
  37. cpu_core and cpu_atom.
  38. For hardware events, they have pre-defined configs (e.g. 0 for cycles).
  39. But on hybrid platform, kernel needs to know where the event comes from
  40. (from atom or from core). The original perf event type PERF_TYPE_HARDWARE
  41. can't carry pmu information. So now this type is extended to be PMU aware
  42. type. The PMU type ID is stored at attr.config[63:32].
  43. PMU type ID is retrieved from sysfs.
  44. /sys/devices/cpu_atom/type
  45. /sys/devices/cpu_core/type
  46. The new attr.config layout for PERF_TYPE_HARDWARE:
  47. PERF_TYPE_HARDWARE: 0xEEEEEEEE000000AA
  48. AA: hardware event ID
  49. EEEEEEEE: PMU type ID
  50. Cache event is similar. The type PERF_TYPE_HW_CACHE is extended to be
  51. PMU aware type. The PMU type ID is stored at attr.config[63:32].
  52. The new attr.config layout for PERF_TYPE_HW_CACHE:
  53. PERF_TYPE_HW_CACHE: 0xEEEEEEEE00DDCCBB
  54. BB: hardware cache ID
  55. CC: hardware cache op ID
  56. DD: hardware cache op result ID
  57. EEEEEEEE: PMU type ID
  58. When enabling a hardware event without specified pmu, such as,
  59. perf stat -e cycles -a (use system-wide in this example), two events
  60. are created automatically.
  61. ------------------------------------------------------------
  62. perf_event_attr:
  63. size 120
  64. config 0x400000000
  65. sample_type IDENTIFIER
  66. read_format TOTAL_TIME_ENABLED|TOTAL_TIME_RUNNING
  67. disabled 1
  68. inherit 1
  69. exclude_guest 1
  70. ------------------------------------------------------------
  71. and
  72. ------------------------------------------------------------
  73. perf_event_attr:
  74. size 120
  75. config 0x800000000
  76. sample_type IDENTIFIER
  77. read_format TOTAL_TIME_ENABLED|TOTAL_TIME_RUNNING
  78. disabled 1
  79. inherit 1
  80. exclude_guest 1
  81. ------------------------------------------------------------
  82. type 0 is PERF_TYPE_HARDWARE.
  83. 0x4 in 0x400000000 indicates it's cpu_core pmu.
  84. 0x8 in 0x800000000 indicates it's cpu_atom pmu (atom pmu type id is random).
  85. The kernel creates 'cycles' (0x400000000) on cpu0-cpu15 (core cpus),
  86. and create 'cycles' (0x800000000) on cpu16-cpu23 (atom cpus).
  87. For perf-stat result, it displays two events:
  88. Performance counter stats for 'system wide':
  89. 6,744,979 cpu_core/cycles/
  90. 1,965,552 cpu_atom/cycles/
  91. The first 'cycles' is core event, the second 'cycles' is atom event.
  92. Thread mode example:
  93. perf-stat reports the scaled counts for hybrid event and with a percentage
  94. displayed. The percentage is the event's running time/enabling time.
  95. One example, 'triad_loop' runs on cpu16 (atom core), while we can see the
  96. scaled value for core cycles is 160,444,092 and the percentage is 0.47%.
  97. perf stat -e cycles \-- taskset -c 16 ./triad_loop
  98. As previous, two events are created.
  99. ------------------------------------------------------------
  100. perf_event_attr:
  101. size 120
  102. config 0x400000000
  103. sample_type IDENTIFIER
  104. read_format TOTAL_TIME_ENABLED|TOTAL_TIME_RUNNING
  105. disabled 1
  106. inherit 1
  107. enable_on_exec 1
  108. exclude_guest 1
  109. ------------------------------------------------------------
  110. and
  111. ------------------------------------------------------------
  112. perf_event_attr:
  113. size 120
  114. config 0x800000000
  115. sample_type IDENTIFIER
  116. read_format TOTAL_TIME_ENABLED|TOTAL_TIME_RUNNING
  117. disabled 1
  118. inherit 1
  119. enable_on_exec 1
  120. exclude_guest 1
  121. ------------------------------------------------------------
  122. Performance counter stats for 'taskset -c 16 ./triad_loop':
  123. 233,066,666 cpu_core/cycles/ (0.43%)
  124. 604,097,080 cpu_atom/cycles/ (99.57%)
  125. perf-record:
  126. If there is no '-e' specified in perf record, on hybrid platform,
  127. it creates two default 'cycles' and adds them to event list. One
  128. is for core, the other is for atom.
  129. perf-stat:
  130. If there is no '-e' specified in perf stat, on hybrid platform,
  131. besides of software events, following events are created and
  132. added to event list in order.
  133. cpu_core/cycles/,
  134. cpu_atom/cycles/,
  135. cpu_core/instructions/,
  136. cpu_atom/instructions/,
  137. cpu_core/branches/,
  138. cpu_atom/branches/,
  139. cpu_core/branch-misses/,
  140. cpu_atom/branch-misses/
  141. Of course, both perf-stat and perf-record support to enable
  142. hybrid event with a specific pmu.
  143. e.g.
  144. perf stat -e cpu_core/cycles/
  145. perf stat -e cpu_atom/cycles/
  146. perf stat -e cpu_core/r1a/
  147. perf stat -e cpu_atom/L1-icache-loads/
  148. perf stat -e cpu_core/cycles/,cpu_atom/instructions/
  149. perf stat -e '{cpu_core/cycles/,cpu_core/instructions/}'
  150. But '{cpu_core/cycles/,cpu_atom/instructions/}' will return
  151. warning and disable grouping, because the pmus in group are
  152. not matched (cpu_core vs. cpu_atom).