~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/perf/Documentation/topdown.txt

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /tools/perf/Documentation/topdown.txt (Version linux-6.12-rc7) and /tools/perf/Documentation/topdown.txt (Version linux-5.15.171)


  1 Using TopDown metrics                          !!   1 Using TopDown metrics in user space
  2 ---------------------                          !!   2 -----------------------------------
  3                                                     3 
  4 TopDown metrics break apart performance bottle !!   4 Intel CPUs (since Sandy Bridge and Silvermont) support a TopDown
  5 1 it is typical to get metrics on retiring, ba !!   5 methodology to break down CPU pipeline execution into 4 bottlenecks:
  6 bound, and backend bound. Higher levels provid !!   6 frontend bound, backend bound, bad speculation, retiring.
  7 level 1 bottlenecks, such as at level 2: core  << 
  8 heavy operations, light operations, branch mis << 
  9 clears, fetch latency and fetch bandwidth. For << 
 10                                                     7 
 11 perf stat --topdown implements this using avai !!   8 For more details on Topdown see [1][5]
 12 per architecture.                              << 
 13                                                     9 
 14 % perf stat -a --topdown -I1000                !!  10 Traditionally this was implemented by events in generic counters
 15 #           time      %  tma_retiring %  tma_b !!  11 and specific formulas to compute the bottlenecks.
 16      1.001141351                 11.5          !!  12 
 17      2.006141972                 13.4          !!  13 perf stat --topdown implements this.
 18      3.010162040                 12.9          << 
 19      4.014009311                 12.5          << 
 20      5.017838554                 11.8          << 
 21      5.704818971                 14.0          << 
 22 ...                                            << 
 23                                                    14 
 24 New Topdown features in Intel Ice Lake         !!  15 Full Top Down includes more levels that can break down the
 25 ======================================         !!  16 bottlenecks further. This is not directly implemented in perf,
                                                   >>  17 but available in other tools that can run on top of perf,
                                                   >>  18 such as toplev[2] or vtune[3]
                                                   >>  19 
                                                   >>  20 New Topdown features in Ice Lake
                                                   >>  21 ===============================
 26                                                    22 
 27 With Ice Lake CPUs the TopDown metrics are dir     23 With Ice Lake CPUs the TopDown metrics are directly available as
 28 fixed counters and do not require generic coun     24 fixed counters and do not require generic counters. This allows
 29 to collect TopDown always in addition to other     25 to collect TopDown always in addition to other events.
 30                                                    26 
 31 Using TopDown through RDPMC in applications on !!  27 % perf stat -a --topdown -I1000
 32 ============================================== !!  28 #           time             retiring      bad speculation       frontend bound        backend bound
                                                   >>  29      1.001281330                23.0%                15.3%                29.6%                32.1%
                                                   >>  30      2.003009005                 5.0%                 6.8%                46.6%                41.6%
                                                   >>  31      3.004646182                 6.7%                 6.7%                46.0%                40.6%
                                                   >>  32      4.006326375                 5.0%                 6.4%                47.6%                41.0%
                                                   >>  33      5.007991804                 5.1%                 6.3%                46.3%                42.3%
                                                   >>  34      6.009626773                 6.2%                 7.1%                47.3%                39.3%
                                                   >>  35      7.011296356                 4.7%                 6.7%                46.2%                42.4%
                                                   >>  36      8.012951831                 4.7%                 6.7%                47.5%                41.1%
                                                   >>  37 ...
                                                   >>  38 
                                                   >>  39 This also enables measuring TopDown per thread/process instead
                                                   >>  40 of only per core.
                                                   >>  41 
                                                   >>  42 Using TopDown through RDPMC in applications on Ice Lake
                                                   >>  43 ======================================================
 33                                                    44 
 34 For more fine grained measurements it can be u     45 For more fine grained measurements it can be useful to
 35 access the new  directly from user space. This     46 access the new  directly from user space. This is more complicated,
 36 but drastically lowers overhead.                   47 but drastically lowers overhead.
 37                                                    48 
 38 On Ice Lake, there is a new fixed counter 3: S     49 On Ice Lake, there is a new fixed counter 3: SLOTS, which reports
 39 "pipeline SLOTS" (cycles multiplied by core is     50 "pipeline SLOTS" (cycles multiplied by core issue width) and a
 40 metric register that reports slots ratios for      51 metric register that reports slots ratios for the different bottleneck
 41 categories.                                        52 categories.
 42                                                    53 
 43 The metrics counter is CPU model specific and      54 The metrics counter is CPU model specific and is not available on older
 44 CPUs.                                              55 CPUs.
 45                                                    56 
 46 Example code                                       57 Example code
 47 ============                                       58 ============
 48                                                    59 
 49 Library functions to do the functionality desc     60 Library functions to do the functionality described below
 50 is also available in libjevents [4]                61 is also available in libjevents [4]
 51                                                    62 
 52 The application opens a group with fixed count     63 The application opens a group with fixed counter 3 (SLOTS) and any
 53 metric event, and allow user programs to read      64 metric event, and allow user programs to read the performance counters.
 54                                                    65 
 55 Fixed counter 3 is mapped to a pseudo event ev     66 Fixed counter 3 is mapped to a pseudo event event=0x00, umask=04,
 56 so the perf_event_attr structure should be ini     67 so the perf_event_attr structure should be initialized with
 57 { .config = 0x0400, .type = PERF_TYPE_RAW }        68 { .config = 0x0400, .type = PERF_TYPE_RAW }
 58 The metric events are mapped to the pseudo eve     69 The metric events are mapped to the pseudo event event=0x00, umask=0x8X.
 59 For example, the perf_event_attr structure can     70 For example, the perf_event_attr structure can be initialized with
 60 { .config = 0x8000, .type = PERF_TYPE_RAW } fo     71 { .config = 0x8000, .type = PERF_TYPE_RAW } for Retiring metric event
 61 The Fixed counter 3 must be the leader of the      72 The Fixed counter 3 must be the leader of the group.
 62                                                    73 
 63 #include <linux/perf_event.h>                      74 #include <linux/perf_event.h>
 64 #include <sys/mman.h>                              75 #include <sys/mman.h>
 65 #include <sys/syscall.h>                           76 #include <sys/syscall.h>
 66 #include <unistd.h>                                77 #include <unistd.h>
 67                                                    78 
 68 /* Provide own perf_event_open stub because gl     79 /* Provide own perf_event_open stub because glibc doesn't */
 69 __attribute__((weak))                              80 __attribute__((weak))
 70 int perf_event_open(struct perf_event_attr *at     81 int perf_event_open(struct perf_event_attr *attr, pid_t pid,
 71                     int cpu, int group_fd, uns     82                     int cpu, int group_fd, unsigned long flags)
 72 {                                                  83 {
 73         return syscall(__NR_perf_event_open, a     84         return syscall(__NR_perf_event_open, attr, pid, cpu, group_fd, flags);
 74 }                                                  85 }
 75                                                    86 
 76 /* Open slots counter file descriptor for curr     87 /* Open slots counter file descriptor for current task. */
 77 struct perf_event_attr slots = {                   88 struct perf_event_attr slots = {
 78         .type = PERF_TYPE_RAW,                     89         .type = PERF_TYPE_RAW,
 79         .size = sizeof(struct perf_event_attr)     90         .size = sizeof(struct perf_event_attr),
 80         .config = 0x400,                           91         .config = 0x400,
 81         .exclude_kernel = 1,                       92         .exclude_kernel = 1,
 82 };                                                 93 };
 83                                                    94 
 84 int slots_fd = perf_event_open(&slots, 0, -1,      95 int slots_fd = perf_event_open(&slots, 0, -1, -1, 0);
 85 if (slots_fd < 0)                                  96 if (slots_fd < 0)
 86         ... error ...                              97         ... error ...
 87                                                    98 
 88 /* Memory mapping the fd permits _rdpmc calls      99 /* Memory mapping the fd permits _rdpmc calls from userspace */
 89 void *slots_p = mmap(0, getpagesize(), PROT_RE    100 void *slots_p = mmap(0, getpagesize(), PROT_READ, MAP_SHARED, slots_fd, 0);
 90 if (!slot_p)                                      101 if (!slot_p)
 91         .... error ...                            102         .... error ...
 92                                                   103 
 93 /*                                                104 /*
 94  * Open metrics event file descriptor for curr    105  * Open metrics event file descriptor for current task.
 95  * Set slots event as the leader of the group.    106  * Set slots event as the leader of the group.
 96  */                                               107  */
 97 struct perf_event_attr metrics = {                108 struct perf_event_attr metrics = {
 98         .type = PERF_TYPE_RAW,                    109         .type = PERF_TYPE_RAW,
 99         .size = sizeof(struct perf_event_attr)    110         .size = sizeof(struct perf_event_attr),
100         .config = 0x8000,                         111         .config = 0x8000,
101         .exclude_kernel = 1,                      112         .exclude_kernel = 1,
102 };                                                113 };
103                                                   114 
104 int metrics_fd = perf_event_open(&metrics, 0,     115 int metrics_fd = perf_event_open(&metrics, 0, -1, slots_fd, 0);
105 if (metrics_fd < 0)                               116 if (metrics_fd < 0)
106         ... error ...                             117         ... error ...
107                                                   118 
108 /* Memory mapping the fd permits _rdpmc calls     119 /* Memory mapping the fd permits _rdpmc calls from userspace */
109 void *metrics_p = mmap(0, getpagesize(), PROT_    120 void *metrics_p = mmap(0, getpagesize(), PROT_READ, MAP_SHARED, metrics_fd, 0);
110 if (!metrics_p)                                   121 if (!metrics_p)
111         ... error ...                             122         ... error ...
112                                                   123 
113 Note: the file descriptors returned by the per    124 Note: the file descriptors returned by the perf_event_open calls must be memory
114 mapped to permit calls to the _rdpmd instructi    125 mapped to permit calls to the _rdpmd instruction. Permission may also be granted
115 by writing the /sys/devices/cpu/rdpmc sysfs no    126 by writing the /sys/devices/cpu/rdpmc sysfs node.
116                                                   127 
117 The RDPMC instruction (or _rdpmc compiler intr    128 The RDPMC instruction (or _rdpmc compiler intrinsic) can now be used
118 to read slots and the topdown metrics at diffe    129 to read slots and the topdown metrics at different points of the program:
119                                                   130 
120 #include <stdint.h>                               131 #include <stdint.h>
121 #include <x86intrin.h>                            132 #include <x86intrin.h>
122                                                   133 
123 #define RDPMC_FIXED     (1 << 30)       /* ret    134 #define RDPMC_FIXED     (1 << 30)       /* return fixed counters */
124 #define RDPMC_METRIC    (1 << 29)       /* ret    135 #define RDPMC_METRIC    (1 << 29)       /* return metric counters */
125                                                   136 
126 #define FIXED_COUNTER_SLOTS             3         137 #define FIXED_COUNTER_SLOTS             3
127 #define METRIC_COUNTER_TOPDOWN_L1_L2    0         138 #define METRIC_COUNTER_TOPDOWN_L1_L2    0
128                                                   139 
129 static inline uint64_t read_slots(void)           140 static inline uint64_t read_slots(void)
130 {                                                 141 {
131         return _rdpmc(RDPMC_FIXED | FIXED_COUN    142         return _rdpmc(RDPMC_FIXED | FIXED_COUNTER_SLOTS);
132 }                                                 143 }
133                                                   144 
134 static inline uint64_t read_metrics(void)         145 static inline uint64_t read_metrics(void)
135 {                                                 146 {
136         return _rdpmc(RDPMC_METRIC | METRIC_CO    147         return _rdpmc(RDPMC_METRIC | METRIC_COUNTER_TOPDOWN_L1_L2);
137 }                                                 148 }
138                                                   149 
139 Then the program can be instrumented to read t    150 Then the program can be instrumented to read these metrics at different
140 points.                                           151 points.
141                                                   152 
142 It's not a good idea to do this with too short    153 It's not a good idea to do this with too short code regions,
143 as the parallelism and overlap in the CPU prog    154 as the parallelism and overlap in the CPU program execution will
144 cause too much measurement inaccuracy. For exa    155 cause too much measurement inaccuracy. For example instrumenting
145 individual basic blocks is definitely too fine    156 individual basic blocks is definitely too fine grained.
146                                                   157 
147 _rdpmc calls should not be mixed with reading     158 _rdpmc calls should not be mixed with reading the metrics and slots counters
148 through system calls, as the kernel will reset    159 through system calls, as the kernel will reset these counters after each system
149 call.                                             160 call.
150                                                   161 
151 Decoding metrics values                           162 Decoding metrics values
152 =======================                           163 =======================
153                                                   164 
154 The value reported by read_metrics() contains     165 The value reported by read_metrics() contains four 8 bit fields
155 that represent a scaled ratio that represent t    166 that represent a scaled ratio that represent the Level 1 bottleneck.
156 All four fields add up to 0xff (= 100%)           167 All four fields add up to 0xff (= 100%)
157                                                   168 
158 The binary ratios in the metric value can be c    169 The binary ratios in the metric value can be converted to float ratios:
159                                                   170 
160 #define GET_METRIC(m, i) (((m) >> (i*8)) & 0xf    171 #define GET_METRIC(m, i) (((m) >> (i*8)) & 0xff)
161                                                   172 
162 /* L1 Topdown metric events */                    173 /* L1 Topdown metric events */
163 #define TOPDOWN_RETIRING(val)   ((float)GET_ME    174 #define TOPDOWN_RETIRING(val)   ((float)GET_METRIC(val, 0) / 0xff)
164 #define TOPDOWN_BAD_SPEC(val)   ((float)GET_ME    175 #define TOPDOWN_BAD_SPEC(val)   ((float)GET_METRIC(val, 1) / 0xff)
165 #define TOPDOWN_FE_BOUND(val)   ((float)GET_ME    176 #define TOPDOWN_FE_BOUND(val)   ((float)GET_METRIC(val, 2) / 0xff)
166 #define TOPDOWN_BE_BOUND(val)   ((float)GET_ME    177 #define TOPDOWN_BE_BOUND(val)   ((float)GET_METRIC(val, 3) / 0xff)
167                                                   178 
168 /*                                                179 /*
169  * L2 Topdown metric events.                      180  * L2 Topdown metric events.
170  * Available on Sapphire Rapids and later plat    181  * Available on Sapphire Rapids and later platforms.
171  */                                               182  */
172 #define TOPDOWN_HEAVY_OPS(val)          ((floa    183 #define TOPDOWN_HEAVY_OPS(val)          ((float)GET_METRIC(val, 4) / 0xff)
173 #define TOPDOWN_BR_MISPREDICT(val)      ((floa    184 #define TOPDOWN_BR_MISPREDICT(val)      ((float)GET_METRIC(val, 5) / 0xff)
174 #define TOPDOWN_FETCH_LAT(val)          ((floa    185 #define TOPDOWN_FETCH_LAT(val)          ((float)GET_METRIC(val, 6) / 0xff)
175 #define TOPDOWN_MEM_BOUND(val)          ((floa    186 #define TOPDOWN_MEM_BOUND(val)          ((float)GET_METRIC(val, 7) / 0xff)
176                                                   187 
177 and then converted to percent for printing.       188 and then converted to percent for printing.
178                                                   189 
179 The ratios in the metric accumulate for the ti    190 The ratios in the metric accumulate for the time when the counter
180 is enabled. For measuring programs it is often    191 is enabled. For measuring programs it is often useful to measure
181 specific sections. For this it is needed to de    192 specific sections. For this it is needed to deltas on metrics.
182                                                   193 
183 This can be done by scaling the metrics with t    194 This can be done by scaling the metrics with the slots counter
184 read at the same time.                            195 read at the same time.
185                                                   196 
186 Then it's possible to take deltas of these slo    197 Then it's possible to take deltas of these slots counts
187 measured at different points, and determine th    198 measured at different points, and determine the metrics
188 for that time period.                             199 for that time period.
189                                                   200 
190         slots_a = read_slots();                   201         slots_a = read_slots();
191         metric_a = read_metrics();                202         metric_a = read_metrics();
192                                                   203 
193         ... larger code region ...                204         ... larger code region ...
194                                                   205 
195         slots_b = read_slots()                    206         slots_b = read_slots()
196         metric_b = read_metrics()                 207         metric_b = read_metrics()
197                                                   208 
198         # compute scaled metrics for measureme    209         # compute scaled metrics for measurement a
199         retiring_slots_a = GET_METRIC(metric_a    210         retiring_slots_a = GET_METRIC(metric_a, 0) * slots_a
200         bad_spec_slots_a = GET_METRIC(metric_a    211         bad_spec_slots_a = GET_METRIC(metric_a, 1) * slots_a
201         fe_bound_slots_a = GET_METRIC(metric_a    212         fe_bound_slots_a = GET_METRIC(metric_a, 2) * slots_a
202         be_bound_slots_a = GET_METRIC(metric_a    213         be_bound_slots_a = GET_METRIC(metric_a, 3) * slots_a
203                                                   214 
204         # compute delta scaled metrics between    215         # compute delta scaled metrics between b and a
205         retiring_slots = GET_METRIC(metric_b,     216         retiring_slots = GET_METRIC(metric_b, 0) * slots_b - retiring_slots_a
206         bad_spec_slots = GET_METRIC(metric_b,     217         bad_spec_slots = GET_METRIC(metric_b, 1) * slots_b - bad_spec_slots_a
207         fe_bound_slots = GET_METRIC(metric_b,     218         fe_bound_slots = GET_METRIC(metric_b, 2) * slots_b - fe_bound_slots_a
208         be_bound_slots = GET_METRIC(metric_b,     219         be_bound_slots = GET_METRIC(metric_b, 3) * slots_b - be_bound_slots_a
209                                                   220 
210 Later the individual ratios of L1 metric event    221 Later the individual ratios of L1 metric events for the measurement period can
211 be recreated from these counts.                   222 be recreated from these counts.
212                                                   223 
213         slots_delta = slots_b - slots_a           224         slots_delta = slots_b - slots_a
214         retiring_ratio = (float)retiring_slots    225         retiring_ratio = (float)retiring_slots / slots_delta
215         bad_spec_ratio = (float)bad_spec_slots    226         bad_spec_ratio = (float)bad_spec_slots / slots_delta
216         fe_bound_ratio = (float)fe_bound_slots    227         fe_bound_ratio = (float)fe_bound_slots / slots_delta
217         be_bound_ratio = (float)be_bound_slots    228         be_bound_ratio = (float)be_bound_slots / slota_delta
218                                                   229 
219         printf("Retiring %.2f%% Bad Speculatio    230         printf("Retiring %.2f%% Bad Speculation %.2f%% FE Bound %.2f%% BE Bound %.2f%%\n",
220                 retiring_ratio * 100.,            231                 retiring_ratio * 100.,
221                 bad_spec_ratio * 100.,            232                 bad_spec_ratio * 100.,
222                 fe_bound_ratio * 100.,            233                 fe_bound_ratio * 100.,
223                 be_bound_ratio * 100.);           234                 be_bound_ratio * 100.);
224                                                   235 
225 The individual ratios of L2 metric events for     236 The individual ratios of L2 metric events for the measurement period can be
226 recreated from L1 and L2 metric counters. (Ava    237 recreated from L1 and L2 metric counters. (Available on Sapphire Rapids and
227 later platforms)                                  238 later platforms)
228                                                   239 
229         # compute scaled metrics for measureme    240         # compute scaled metrics for measurement a
230         heavy_ops_slots_a = GET_METRIC(metric_    241         heavy_ops_slots_a = GET_METRIC(metric_a, 4) * slots_a
231         br_mispredict_slots_a = GET_METRIC(met    242         br_mispredict_slots_a = GET_METRIC(metric_a, 5) * slots_a
232         fetch_lat_slots_a = GET_METRIC(metric_    243         fetch_lat_slots_a = GET_METRIC(metric_a, 6) * slots_a
233         mem_bound_slots_a = GET_METRIC(metric_    244         mem_bound_slots_a = GET_METRIC(metric_a, 7) * slots_a
234                                                   245 
235         # compute delta scaled metrics between    246         # compute delta scaled metrics between b and a
236         heavy_ops_slots = GET_METRIC(metric_b,    247         heavy_ops_slots = GET_METRIC(metric_b, 4) * slots_b - heavy_ops_slots_a
237         br_mispredict_slots = GET_METRIC(metri    248         br_mispredict_slots = GET_METRIC(metric_b, 5) * slots_b - br_mispredict_slots_a
238         fetch_lat_slots = GET_METRIC(metric_b,    249         fetch_lat_slots = GET_METRIC(metric_b, 6) * slots_b - fetch_lat_slots_a
239         mem_bound_slots = GET_METRIC(metric_b,    250         mem_bound_slots = GET_METRIC(metric_b, 7) * slots_b - mem_bound_slots_a
240                                                   251 
241         slots_delta = slots_b - slots_a           252         slots_delta = slots_b - slots_a
242         heavy_ops_ratio = (float)heavy_ops_slo    253         heavy_ops_ratio = (float)heavy_ops_slots / slots_delta
243         light_ops_ratio = retiring_ratio - hea    254         light_ops_ratio = retiring_ratio - heavy_ops_ratio;
244                                                   255 
245         br_mispredict_ratio = (float)br_mispre    256         br_mispredict_ratio = (float)br_mispredict_slots / slots_delta
246         machine_clears_ratio = bad_spec_ratio     257         machine_clears_ratio = bad_spec_ratio - br_mispredict_ratio;
247                                                   258 
248         fetch_lat_ratio = (float)fetch_lat_slo    259         fetch_lat_ratio = (float)fetch_lat_slots / slots_delta
249         fetch_bw_ratio = fe_bound_ratio - fetc    260         fetch_bw_ratio = fe_bound_ratio - fetch_lat_ratio;
250                                                   261 
251         mem_bound_ratio = (float)mem_bound_slo    262         mem_bound_ratio = (float)mem_bound_slots / slota_delta
252         core_bound_ratio = be_bound_ratio - me    263         core_bound_ratio = be_bound_ratio - mem_bound_ratio;
253                                                   264 
254         printf("Heavy Operations %.2f%% Light     265         printf("Heavy Operations %.2f%% Light Operations %.2f%% "
255                "Branch Mispredict %.2f%% Machi    266                "Branch Mispredict %.2f%% Machine Clears %.2f%% "
256                "Fetch Latency %.2f%% Fetch Ban    267                "Fetch Latency %.2f%% Fetch Bandwidth %.2f%% "
257                "Mem Bound %.2f%% Core Bound %.    268                "Mem Bound %.2f%% Core Bound %.2f%%\n",
258                 heavy_ops_ratio * 100.,           269                 heavy_ops_ratio * 100.,
259                 light_ops_ratio * 100.,           270                 light_ops_ratio * 100.,
260                 br_mispredict_ratio * 100.,       271                 br_mispredict_ratio * 100.,
261                 machine_clears_ratio * 100.,      272                 machine_clears_ratio * 100.,
262                 fetch_lat_ratio * 100.,           273                 fetch_lat_ratio * 100.,
263                 fetch_bw_ratio * 100.,            274                 fetch_bw_ratio * 100.,
264                 mem_bound_ratio * 100.,           275                 mem_bound_ratio * 100.,
265                 core_bound_ratio * 100.);         276                 core_bound_ratio * 100.);
266                                                   277 
267 Resetting metrics counters                        278 Resetting metrics counters
268 ==========================                        279 ==========================
269                                                   280 
270 Since the individual metrics are only 8bit the    281 Since the individual metrics are only 8bit they lose precision for
271 short regions over time because the number of     282 short regions over time because the number of cycles covered by each
272 fraction bit shrinks. So the counters need to     283 fraction bit shrinks. So the counters need to be reset regularly.
273                                                   284 
274 When using the kernel perf API the kernel rese    285 When using the kernel perf API the kernel resets on every read.
275 So as long as the reading is at reasonable int    286 So as long as the reading is at reasonable intervals (every few
276 seconds) the precision is good.                   287 seconds) the precision is good.
277                                                   288 
278 When using perf stat it is recommended to alwa    289 When using perf stat it is recommended to always use the -I option,
279 with no longer interval than a few seconds        290 with no longer interval than a few seconds
280                                                   291 
281         perf stat -I 1000 --topdown ...           292         perf stat -I 1000 --topdown ...
282                                                   293 
283 For user programs using RDPMC directly the cou    294 For user programs using RDPMC directly the counter can
284 be reset explicitly using ioctl:                  295 be reset explicitly using ioctl:
285                                                   296 
286         ioctl(perf_fd, PERF_EVENT_IOC_RESET, 0    297         ioctl(perf_fd, PERF_EVENT_IOC_RESET, 0);
287                                                   298 
288 This "opens" a new measurement period.            299 This "opens" a new measurement period.
289                                                   300 
290 A program using RDPMC for TopDown should sched    301 A program using RDPMC for TopDown should schedule such a reset
291 regularly, as in every few seconds.               302 regularly, as in every few seconds.
292                                                   303 
293 Limits on Intel Ice Lake                       !! 304 Limits on Ice Lake
294 ========================                       !! 305 ==================
295                                                   306 
296 Four pseudo TopDown metric events are exposed     307 Four pseudo TopDown metric events are exposed for the end-users,
297 topdown-retiring, topdown-bad-spec, topdown-fe    308 topdown-retiring, topdown-bad-spec, topdown-fe-bound and topdown-be-bound.
298 They can be used to collect the TopDown value     309 They can be used to collect the TopDown value under the following
299 rules:                                            310 rules:
300 - All the TopDown metric events must be in a g    311 - All the TopDown metric events must be in a group with the SLOTS event.
301 - The SLOTS event must be the leader of the gr    312 - The SLOTS event must be the leader of the group.
302 - The PERF_FORMAT_GROUP flag must be applied f    313 - The PERF_FORMAT_GROUP flag must be applied for each TopDown metric
303   events                                          314   events
304                                                   315 
305 The SLOTS event and the TopDown metric events     316 The SLOTS event and the TopDown metric events can be counting members of
306 a sampling read group. Since the SLOTS event m    317 a sampling read group. Since the SLOTS event must be the leader of a TopDown
307 group, the second event of the group is the sa    318 group, the second event of the group is the sampling event.
308 For example, perf record -e '{slots, $sampling    319 For example, perf record -e '{slots, $sampling_event, topdown-retiring}:S'
309                                                   320 
310 Extension on Intel Sapphire Rapids Server      !! 321 Extension on Sapphire Rapids Server
311 =========================================      !! 322 ===================================
312 The metrics counter is extended to support TMA    323 The metrics counter is extended to support TMA method level 2 metrics.
313 The lower half of the register is the TMA leve    324 The lower half of the register is the TMA level 1 metrics (legacy).
314 The upper half is also divided into four 8-bit    325 The upper half is also divided into four 8-bit fields for the new level 2
315 metrics. Four more TopDown metric events are e    326 metrics. Four more TopDown metric events are exposed for the end-users,
316 topdown-heavy-ops, topdown-br-mispredict, topd    327 topdown-heavy-ops, topdown-br-mispredict, topdown-fetch-lat and
317 topdown-mem-bound.                                328 topdown-mem-bound.
318                                                   329 
319 Each of the new level 2 metrics in the upper h    330 Each of the new level 2 metrics in the upper half is a subset of the
320 corresponding level 1 metric in the lower half    331 corresponding level 1 metric in the lower half. Software can deduce the
321 other four level 2 metrics by subtracting corr    332 other four level 2 metrics by subtracting corresponding metrics as below.
322                                                   333 
323     Light_Operations = Retiring - Heavy_Operat    334     Light_Operations = Retiring - Heavy_Operations
324     Machine_Clears = Bad_Speculation - Branch_    335     Machine_Clears = Bad_Speculation - Branch_Mispredicts
325     Fetch_Bandwidth = Frontend_Bound - Fetch_L    336     Fetch_Bandwidth = Frontend_Bound - Fetch_Latency
326     Core_Bound = Backend_Bound - Memory_Bound     337     Core_Bound = Backend_Bound - Memory_Bound
327                                                   338 
328 TPEBS in TopDown                               << 
329 ================                               << 
330                                                << 
331 TPEBS (Timed PEBS) is one of the new Intel PMU << 
332 Rapids microarchitecture. The TPEBS feature ad << 
333 in the Basic Info group of the PEBS record. It << 
334 retirement of the previous instruction to the  << 
335 Please refer to Section 8.4.1 of "Intel® Arch << 
336 Programming Reference" for more details about  << 
337 extends PEBS record, sampling with weight opti << 
338 retire_latency value.                          << 
339                                                << 
340         perf record -e event_name -W ...       << 
341                                                << 
342 In the most recent release of TMA, the metrics << 
343 values in some of the metrics’ formulas on p << 
344 For previous generations that do not support T << 
345 predefined per processor family by the hardwar << 
346 of workloads in execution environments, retire << 
347 time are more accurate. Therefore, new TMA met << 
348 more accurate performance analysis results.    << 
349                                                << 
350 To support TPEBS in TMA metrics, a new modifie << 
351 capture retire_latency value of required event << 
352 with perf record. The retire_latency value wou << 
353 Currently, this feature is supported through p << 
354                                                << 
355         perf stat -M metric_name --record-tpeb << 
356                                                << 
357                                                << 
358                                                   339 
359 [1] https://software.intel.com/en-us/top-down-    340 [1] https://software.intel.com/en-us/top-down-microarchitecture-analysis-method-win
360 [2] https://sites.google.com/site/analysismeth !! 341 [2] https://github.com/andikleen/pmu-tools/wiki/toplev-manual
361 [3] https://perf.wiki.kernel.org/index.php/Top !! 342 [3] https://software.intel.com/en-us/intel-vtune-amplifier-xe
362 [4] https://github.com/andikleen/pmu-tools/tre    343 [4] https://github.com/andikleen/pmu-tools/tree/master/jevents
                                                   >> 344 [5] https://sites.google.com/site/analysismethods/yasin-pubs
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php