2 * Copyright © 2018 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
26 #include <sys/types.h>
32 #include <drm-uapi/i915_drm.h>
34 #include "common/gen_gem.h"
36 #include "gen_perf_regs.h"
37 #include "perf/gen_perf_mdapi.h"
38 #include "perf/gen_perf_metrics.h"
40 #include "dev/gen_debug.h"
41 #include "dev/gen_device_info.h"
42 #include "util/bitscan.h"
43 #include "util/mesa-sha1.h"
44 #include "util/u_math.h"
46 #define FILE_DEBUG_FLAG DEBUG_PERFMON
47 #define MI_RPC_BO_SIZE 4096
48 #define MI_FREQ_START_OFFSET_BYTES (3072)
49 #define MI_RPC_BO_END_OFFSET_BYTES (MI_RPC_BO_SIZE / 2)
50 #define MI_FREQ_END_OFFSET_BYTES (3076)
52 #define INTEL_MASK(high, low) (((1u<<((high)-(low)+1))-1)<<(low))
54 #define GEN7_RPSTAT1 0xA01C
55 #define GEN7_RPSTAT1_CURR_GT_FREQ_SHIFT 7
56 #define GEN7_RPSTAT1_CURR_GT_FREQ_MASK INTEL_MASK(13, 7)
57 #define GEN7_RPSTAT1_PREV_GT_FREQ_SHIFT 0
58 #define GEN7_RPSTAT1_PREV_GT_FREQ_MASK INTEL_MASK(6, 0)
60 #define GEN9_RPSTAT0 0xA01C
61 #define GEN9_RPSTAT0_CURR_GT_FREQ_SHIFT 23
62 #define GEN9_RPSTAT0_CURR_GT_FREQ_MASK INTEL_MASK(31, 23)
63 #define GEN9_RPSTAT0_PREV_GT_FREQ_SHIFT 0
64 #define GEN9_RPSTAT0_PREV_GT_FREQ_MASK INTEL_MASK(8, 0)
66 #define GEN6_SO_PRIM_STORAGE_NEEDED 0x2280
67 #define GEN7_SO_PRIM_STORAGE_NEEDED(n) (0x5240 + (n) * 8)
68 #define GEN6_SO_NUM_PRIMS_WRITTEN 0x2288
69 #define GEN7_SO_NUM_PRIMS_WRITTEN(n) (0x5200 + (n) * 8)
71 #define MAP_READ (1 << 0)
72 #define MAP_WRITE (1 << 1)
75 * Periodic OA samples are read() into these buffer structures via the
76 * i915 perf kernel interface and appended to the
77 * perf_ctx->sample_buffers linked list. When we process the
78 * results of an OA metrics query we need to consider all the periodic
79 * samples between the Begin and End MI_REPORT_PERF_COUNT command
82 * 'Periodic' is a simplification as there are other automatic reports
83 * written by the hardware also buffered here.
85 * Considering three queries, A, B and C:
88 * ________________A_________________
90 * | ________B_________ _____C___________
93 * And an illustration of sample buffers read over this time frame:
94 * [HEAD ][ ][ ][ ][ ][ ][ ][ ][TAIL ]
96 * These nodes may hold samples for query A:
97 * [ ][ ][ A ][ A ][ A ][ A ][ A ][ ][ ]
99 * These nodes may hold samples for query B:
100 * [ ][ ][ B ][ B ][ B ][ ][ ][ ][ ]
102 * These nodes may hold samples for query C:
103 * [ ][ ][ ][ ][ ][ C ][ C ][ C ][ ]
105 * The illustration assumes we have an even distribution of periodic
106 * samples so all nodes have the same size plotted against time:
108 * Note, to simplify code, the list is never empty.
110 * With overlapping queries we can see that periodic OA reports may
111 * relate to multiple queries and care needs to be take to keep
112 * track of sample buffers until there are no queries that might
113 * depend on their contents.
115 * We use a node ref counting system where a reference ensures that a
116 * node and all following nodes can't be freed/recycled until the
117 * reference drops to zero.
119 * E.g. with a ref of one here:
120 * [ 0 ][ 0 ][ 1 ][ 0 ][ 0 ][ 0 ][ 0 ][ 0 ][ 0 ]
122 * These nodes could be freed or recycled ("reaped"):
125 * These must be preserved until the leading ref drops to zero:
126 * [ 1 ][ 0 ][ 0 ][ 0 ][ 0 ][ 0 ][ 0 ]
128 * When a query starts we take a reference on the current tail of
129 * the list, knowing that no already-buffered samples can possibly
130 * relate to the newly-started query. A pointer to this node is
131 * also saved in the query object's ->oa.samples_head.
133 * E.g. starting query A while there are two nodes in .sample_buffers:
134 * ________________A________
138 * ^_______ Add a reference and store pointer to node in
141 * Moving forward to when the B query starts with no new buffer nodes:
142 * (for reference, i915 perf reads() are only done when queries finish)
143 * ________________A_______
148 * ^_______ Add a reference and store pointer to
149 * node in B->oa.samples_head
151 * Once a query is finished, after an OA query has become 'Ready',
152 * once the End OA report has landed and after we we have processed
153 * all the intermediate periodic samples then we drop the
154 * ->oa.samples_head reference we took at the start.
156 * So when the B query has finished we have:
157 * ________________A________
158 * | ______B___________
160 * [ 0 ][ 1 ][ 0 ][ 0 ][ 0 ]
161 * ^_______ Drop B->oa.samples_head reference
163 * We still can't free these due to the A->oa.samples_head ref:
164 * [ 1 ][ 0 ][ 0 ][ 0 ]
166 * When the A query finishes: (note there's a new ref for C's samples_head)
167 * ________________A_________________
171 * [ 0 ][ 0 ][ 0 ][ 0 ][ 1 ][ 0 ][ 0 ]
172 * ^_______ Drop A->oa.samples_head reference
174 * And we can now reap these nodes up to the C->oa.samples_head:
175 * [ X ][ X ][ X ][ X ]
176 * keeping -> [ 1 ][ 0 ][ 0 ]
178 * We reap old sample buffers each time we finish processing an OA
179 * query by iterating the sample_buffers list from the head until we
180 * find a referenced node and stop.
182 * Reaped buffers move to a perfquery.free_sample_buffers list and
183 * when we come to read() we first look to recycle a buffer from the
184 * free_sample_buffers list before allocating a new buffer.
186 struct oa_sample_buf
{
187 struct exec_node link
;
190 uint8_t buf
[I915_PERF_OA_SAMPLE_SIZE
* 10];
191 uint32_t last_timestamp
;
195 * gen representation of a performance query object.
197 * NB: We want to keep this structure relatively lean considering that
198 * applications may expect to allocate enough objects to be able to
199 * query around all draw calls in a frame.
201 struct gen_perf_query_object
203 const struct gen_perf_query_info
*queryinfo
;
205 /* See query->kind to know which state below is in use... */
210 * BO containing OA counter snapshots at query Begin/End time.
215 * Address of mapped of @bo
220 * The MI_REPORT_PERF_COUNT command lets us specify a unique
221 * ID that will be reflected in the resulting OA report
222 * that's written by the GPU. This is the ID we're expecting
223 * in the begin report and the the end report should be
224 * @begin_report_id + 1.
229 * Reference the head of the brw->perfquery.sample_buffers
230 * list at the time that the query started (so we only need
231 * to look at nodes after this point when looking for samples
232 * related to this query)
234 * (See struct brw_oa_sample_buf description for more details)
236 struct exec_node
*samples_head
;
239 * false while in the unaccumulated_elements list, and set to
240 * true when the final, end MI_RPC snapshot has been
243 bool results_accumulated
;
246 * Frequency of the GT at begin and end of the query.
248 uint64_t gt_frequency
[2];
251 * Accumulated OA results between begin and end of the query.
253 struct gen_perf_query_result result
;
258 * BO containing starting and ending snapshots for the
259 * statistics counters.
266 struct gen_perf_context
{
267 struct gen_perf_config
*perf
;
269 void * ctx
; /* driver context (eg, brw_context) */
271 const struct gen_device_info
*devinfo
;
276 /* The i915 perf stream we open to setup + enable the OA counters */
279 /* An i915 perf stream fd gives exclusive access to the OA unit that will
280 * report counter snapshots for a specific counter set/profile in a
281 * specific layout/format so we can only start OA queries that are
282 * compatible with the currently open fd...
284 int current_oa_metrics_set_id
;
285 int current_oa_format
;
287 /* List of buffers containing OA reports */
288 struct exec_list sample_buffers
;
290 /* Cached list of empty sample buffers */
291 struct exec_list free_sample_buffers
;
293 int n_active_oa_queries
;
294 int n_active_pipeline_stats_queries
;
296 /* The number of queries depending on running OA counters which
297 * extends beyond brw_end_perf_query() since we need to wait until
298 * the last MI_RPC command has parsed by the GPU.
300 * Accurate accounting is important here as emitting an
301 * MI_REPORT_PERF_COUNT command while the OA unit is disabled will
302 * effectively hang the gpu.
306 /* To help catch an spurious problem with the hardware or perf
307 * forwarding samples, we emit each MI_REPORT_PERF_COUNT command
308 * with a unique ID that we can explicitly check for...
310 int next_query_start_report_id
;
313 * An array of queries whose results haven't yet been assembled
314 * based on the data in buffer objects.
316 * These may be active, or have already ended. However, the
317 * results have not been requested.
319 struct gen_perf_query_object
**unaccumulated
;
320 int unaccumulated_elements
;
321 int unaccumulated_array_size
;
323 /* The total number of query objects so we can relinquish
324 * our exclusive access to perf if the application deletes
325 * all of its objects. (NB: We only disable perf while
326 * there are no active queries)
328 int n_query_instances
;
331 const struct gen_perf_query_info
*
332 gen_perf_query_info(const struct gen_perf_query_object
*query
)
334 return query
->queryinfo
;
337 struct gen_perf_context
*
338 gen_perf_new_context(void *parent
)
340 struct gen_perf_context
*ctx
= rzalloc(parent
, struct gen_perf_context
);
342 fprintf(stderr
, "%s: failed to alloc context\n", __func__
);
346 struct gen_perf_config
*
347 gen_perf_config(struct gen_perf_context
*ctx
)
352 struct gen_perf_query_object
*
353 gen_perf_new_query(struct gen_perf_context
*perf_ctx
, unsigned query_index
)
355 const struct gen_perf_query_info
*query
=
356 &perf_ctx
->perf
->queries
[query_index
];
357 struct gen_perf_query_object
*obj
=
358 calloc(1, sizeof(struct gen_perf_query_object
));
363 obj
->queryinfo
= query
;
365 perf_ctx
->n_query_instances
++;
370 gen_perf_active_queries(struct gen_perf_context
*perf_ctx
,
371 const struct gen_perf_query_info
*query
)
373 assert(perf_ctx
->n_active_oa_queries
== 0 || perf_ctx
->n_active_pipeline_stats_queries
== 0);
375 switch (query
->kind
) {
376 case GEN_PERF_QUERY_TYPE_OA
:
377 case GEN_PERF_QUERY_TYPE_RAW
:
378 return perf_ctx
->n_active_oa_queries
;
381 case GEN_PERF_QUERY_TYPE_PIPELINE
:
382 return perf_ctx
->n_active_pipeline_stats_queries
;
386 unreachable("Unknown query type");
391 static inline uint64_t to_user_pointer(void *ptr
)
393 return (uintptr_t) ptr
;
397 get_sysfs_dev_dir(struct gen_perf_config
*perf
, int fd
)
402 struct dirent
*drm_entry
;
405 perf
->sysfs_dev_dir
[0] = '\0';
407 if (fstat(fd
, &sb
)) {
408 DBG("Failed to stat DRM fd\n");
412 maj
= major(sb
.st_rdev
);
413 min
= minor(sb
.st_rdev
);
415 if (!S_ISCHR(sb
.st_mode
)) {
416 DBG("DRM fd is not a character device as expected\n");
420 len
= snprintf(perf
->sysfs_dev_dir
,
421 sizeof(perf
->sysfs_dev_dir
),
422 "/sys/dev/char/%d:%d/device/drm", maj
, min
);
423 if (len
< 0 || len
>= sizeof(perf
->sysfs_dev_dir
)) {
424 DBG("Failed to concatenate sysfs path to drm device\n");
428 drmdir
= opendir(perf
->sysfs_dev_dir
);
430 DBG("Failed to open %s: %m\n", perf
->sysfs_dev_dir
);
434 while ((drm_entry
= readdir(drmdir
))) {
435 if ((drm_entry
->d_type
== DT_DIR
||
436 drm_entry
->d_type
== DT_LNK
) &&
437 strncmp(drm_entry
->d_name
, "card", 4) == 0)
439 len
= snprintf(perf
->sysfs_dev_dir
,
440 sizeof(perf
->sysfs_dev_dir
),
441 "/sys/dev/char/%d:%d/device/drm/%s",
442 maj
, min
, drm_entry
->d_name
);
444 if (len
< 0 || len
>= sizeof(perf
->sysfs_dev_dir
))
453 DBG("Failed to find cardX directory under /sys/dev/char/%d:%d/device/drm\n",
460 read_file_uint64(const char *file
, uint64_t *val
)
468 while ((n
= read(fd
, buf
, sizeof (buf
) - 1)) < 0 &&
475 *val
= strtoull(buf
, NULL
, 0);
481 read_sysfs_drm_device_file_uint64(struct gen_perf_config
*perf
,
488 len
= snprintf(buf
, sizeof(buf
), "%s/%s", perf
->sysfs_dev_dir
, file
);
489 if (len
< 0 || len
>= sizeof(buf
)) {
490 DBG("Failed to concatenate sys filename to read u64 from\n");
494 return read_file_uint64(buf
, value
);
497 static inline struct gen_perf_query_info
*
498 append_query_info(struct gen_perf_config
*perf
, int max_counters
)
500 struct gen_perf_query_info
*query
;
502 perf
->queries
= reralloc(perf
, perf
->queries
,
503 struct gen_perf_query_info
,
505 query
= &perf
->queries
[perf
->n_queries
- 1];
506 memset(query
, 0, sizeof(*query
));
508 if (max_counters
> 0) {
509 query
->max_counters
= max_counters
;
511 rzalloc_array(perf
, struct gen_perf_query_counter
, max_counters
);
518 register_oa_config(struct gen_perf_config
*perf
,
519 const struct gen_perf_query_info
*query
,
522 struct gen_perf_query_info
*registered_query
= append_query_info(perf
, 0);
524 *registered_query
= *query
;
525 registered_query
->oa_metrics_set_id
= config_id
;
526 DBG("metric set registered: id = %" PRIu64
", guid = %s\n",
527 registered_query
->oa_metrics_set_id
, query
->guid
);
531 enumerate_sysfs_metrics(struct gen_perf_config
*perf
)
533 DIR *metricsdir
= NULL
;
534 struct dirent
*metric_entry
;
538 len
= snprintf(buf
, sizeof(buf
), "%s/metrics", perf
->sysfs_dev_dir
);
539 if (len
< 0 || len
>= sizeof(buf
)) {
540 DBG("Failed to concatenate path to sysfs metrics/ directory\n");
544 metricsdir
= opendir(buf
);
546 DBG("Failed to open %s: %m\n", buf
);
550 while ((metric_entry
= readdir(metricsdir
))) {
551 struct hash_entry
*entry
;
553 if ((metric_entry
->d_type
!= DT_DIR
&&
554 metric_entry
->d_type
!= DT_LNK
) ||
555 metric_entry
->d_name
[0] == '.')
558 DBG("metric set: %s\n", metric_entry
->d_name
);
559 entry
= _mesa_hash_table_search(perf
->oa_metrics_table
,
560 metric_entry
->d_name
);
563 if (!gen_perf_load_metric_id(perf
, metric_entry
->d_name
, &id
)) {
564 DBG("Failed to read metric set id from %s: %m", buf
);
568 register_oa_config(perf
, (const struct gen_perf_query_info
*)entry
->data
, id
);
570 DBG("metric set not known by mesa (skipping)\n");
573 closedir(metricsdir
);
577 kernel_has_dynamic_config_support(struct gen_perf_config
*perf
, int fd
)
579 uint64_t invalid_config_id
= UINT64_MAX
;
581 return gen_ioctl(fd
, DRM_IOCTL_I915_PERF_REMOVE_CONFIG
,
582 &invalid_config_id
) < 0 && errno
== ENOENT
;
586 i915_query_items(struct gen_perf_config
*perf
, int fd
,
587 struct drm_i915_query_item
*items
, uint32_t n_items
)
589 struct drm_i915_query q
= {
590 .num_items
= n_items
,
591 .items_ptr
= to_user_pointer(items
),
593 return gen_ioctl(fd
, DRM_IOCTL_I915_QUERY
, &q
);
597 i915_query_perf_config_supported(struct gen_perf_config
*perf
, int fd
)
599 struct drm_i915_query_item item
= {
600 .query_id
= DRM_I915_QUERY_PERF_CONFIG
,
601 .flags
= DRM_I915_QUERY_PERF_CONFIG_LIST
,
604 return i915_query_items(perf
, fd
, &item
, 1) == 0 && item
.length
> 0;
608 i915_query_perf_config_data(struct gen_perf_config
*perf
,
609 int fd
, const char *guid
,
610 struct drm_i915_perf_oa_config
*config
)
613 struct drm_i915_query_perf_config query
;
614 struct drm_i915_perf_oa_config config
;
616 struct drm_i915_query_item item
= {
617 .query_id
= DRM_I915_QUERY_PERF_CONFIG
,
618 .flags
= DRM_I915_QUERY_PERF_CONFIG_DATA_FOR_UUID
,
619 .data_ptr
= to_user_pointer(&item_data
),
620 .length
= sizeof(item_data
),
623 memset(&item_data
, 0, sizeof(item_data
));
624 memcpy(item_data
.query
.uuid
, guid
, sizeof(item_data
.query
.uuid
));
625 memcpy(&item_data
.config
, config
, sizeof(item_data
.config
));
627 if (!(i915_query_items(perf
, fd
, &item
, 1) == 0 && item
.length
> 0))
630 memcpy(config
, &item_data
.config
, sizeof(item_data
.config
));
636 gen_perf_load_metric_id(struct gen_perf_config
*perf_cfg
,
640 char config_path
[280];
642 snprintf(config_path
, sizeof(config_path
), "%s/metrics/%s/id",
643 perf_cfg
->sysfs_dev_dir
, guid
);
645 /* Don't recreate already loaded configs. */
646 return read_file_uint64(config_path
, metric_id
);
650 i915_add_config(struct gen_perf_config
*perf
, int fd
,
651 const struct gen_perf_registers
*config
,
654 struct drm_i915_perf_oa_config i915_config
= { 0, };
656 memcpy(i915_config
.uuid
, guid
, sizeof(i915_config
.uuid
));
658 i915_config
.n_mux_regs
= config
->n_mux_regs
;
659 i915_config
.mux_regs_ptr
= to_user_pointer(config
->mux_regs
);
661 i915_config
.n_boolean_regs
= config
->n_b_counter_regs
;
662 i915_config
.boolean_regs_ptr
= to_user_pointer(config
->b_counter_regs
);
664 i915_config
.n_flex_regs
= config
->n_flex_regs
;
665 i915_config
.flex_regs_ptr
= to_user_pointer(config
->flex_regs
);
667 int ret
= gen_ioctl(fd
, DRM_IOCTL_I915_PERF_ADD_CONFIG
, &i915_config
);
668 return ret
> 0 ? ret
: 0;
672 init_oa_configs(struct gen_perf_config
*perf
, int fd
)
674 hash_table_foreach(perf
->oa_metrics_table
, entry
) {
675 const struct gen_perf_query_info
*query
= entry
->data
;
678 if (gen_perf_load_metric_id(perf
, query
->guid
, &config_id
)) {
679 DBG("metric set: %s (already loaded)\n", query
->guid
);
680 register_oa_config(perf
, query
, config_id
);
684 int ret
= i915_add_config(perf
, fd
, &query
->config
, query
->guid
);
686 DBG("Failed to load \"%s\" (%s) metrics set in kernel: %s\n",
687 query
->name
, query
->guid
, strerror(errno
));
691 register_oa_config(perf
, query
, ret
);
692 DBG("metric set: %s (added)\n", query
->guid
);
697 compute_topology_builtins(struct gen_perf_config
*perf
,
698 const struct gen_device_info
*devinfo
)
700 perf
->sys_vars
.slice_mask
= devinfo
->slice_masks
;
701 perf
->sys_vars
.n_eu_slices
= devinfo
->num_slices
;
703 for (int i
= 0; i
< sizeof(devinfo
->subslice_masks
[i
]); i
++) {
704 perf
->sys_vars
.n_eu_sub_slices
+=
705 __builtin_popcount(devinfo
->subslice_masks
[i
]);
708 for (int i
= 0; i
< sizeof(devinfo
->eu_masks
); i
++)
709 perf
->sys_vars
.n_eus
+= __builtin_popcount(devinfo
->eu_masks
[i
]);
711 perf
->sys_vars
.eu_threads_count
= devinfo
->num_thread_per_eu
;
713 /* The subslice mask builtin contains bits for all slices. Prior to Gen11
714 * it had groups of 3bits for each slice, on Gen11 it's 8bits for each
717 * Ideally equations would be updated to have a slice/subslice query
720 perf
->sys_vars
.subslice_mask
= 0;
722 int bits_per_subslice
= devinfo
->gen
== 11 ? 8 : 3;
724 for (int s
= 0; s
< util_last_bit(devinfo
->slice_masks
); s
++) {
725 for (int ss
= 0; ss
< (devinfo
->subslice_slice_stride
* 8); ss
++) {
726 if (gen_device_info_subslice_available(devinfo
, s
, ss
))
727 perf
->sys_vars
.subslice_mask
|= 1ULL << (s
* bits_per_subslice
+ ss
);
733 init_oa_sys_vars(struct gen_perf_config
*perf
, const struct gen_device_info
*devinfo
)
735 uint64_t min_freq_mhz
= 0, max_freq_mhz
= 0;
737 if (!read_sysfs_drm_device_file_uint64(perf
, "gt_min_freq_mhz", &min_freq_mhz
))
740 if (!read_sysfs_drm_device_file_uint64(perf
, "gt_max_freq_mhz", &max_freq_mhz
))
743 memset(&perf
->sys_vars
, 0, sizeof(perf
->sys_vars
));
744 perf
->sys_vars
.gt_min_freq
= min_freq_mhz
* 1000000;
745 perf
->sys_vars
.gt_max_freq
= max_freq_mhz
* 1000000;
746 perf
->sys_vars
.timestamp_frequency
= devinfo
->timestamp_frequency
;
747 perf
->sys_vars
.revision
= devinfo
->revision
;
748 compute_topology_builtins(perf
, devinfo
);
753 typedef void (*perf_register_oa_queries_t
)(struct gen_perf_config
*);
755 static perf_register_oa_queries_t
756 get_register_queries_function(const struct gen_device_info
*devinfo
)
758 if (devinfo
->is_haswell
)
759 return gen_oa_register_queries_hsw
;
760 if (devinfo
->is_cherryview
)
761 return gen_oa_register_queries_chv
;
762 if (devinfo
->is_broadwell
)
763 return gen_oa_register_queries_bdw
;
764 if (devinfo
->is_broxton
)
765 return gen_oa_register_queries_bxt
;
766 if (devinfo
->is_skylake
) {
767 if (devinfo
->gt
== 2)
768 return gen_oa_register_queries_sklgt2
;
769 if (devinfo
->gt
== 3)
770 return gen_oa_register_queries_sklgt3
;
771 if (devinfo
->gt
== 4)
772 return gen_oa_register_queries_sklgt4
;
774 if (devinfo
->is_kabylake
) {
775 if (devinfo
->gt
== 2)
776 return gen_oa_register_queries_kblgt2
;
777 if (devinfo
->gt
== 3)
778 return gen_oa_register_queries_kblgt3
;
780 if (devinfo
->is_geminilake
)
781 return gen_oa_register_queries_glk
;
782 if (devinfo
->is_coffeelake
) {
783 if (devinfo
->gt
== 2)
784 return gen_oa_register_queries_cflgt2
;
785 if (devinfo
->gt
== 3)
786 return gen_oa_register_queries_cflgt3
;
788 if (devinfo
->is_cannonlake
)
789 return gen_oa_register_queries_cnl
;
790 if (devinfo
->gen
== 11)
791 return gen_oa_register_queries_icl
;
797 add_stat_reg(struct gen_perf_query_info
*query
, uint32_t reg
,
798 uint32_t numerator
, uint32_t denominator
,
799 const char *name
, const char *description
)
801 struct gen_perf_query_counter
*counter
;
803 assert(query
->n_counters
< query
->max_counters
);
805 counter
= &query
->counters
[query
->n_counters
];
806 counter
->name
= name
;
807 counter
->desc
= description
;
808 counter
->type
= GEN_PERF_COUNTER_TYPE_RAW
;
809 counter
->data_type
= GEN_PERF_COUNTER_DATA_TYPE_UINT64
;
810 counter
->offset
= sizeof(uint64_t) * query
->n_counters
;
811 counter
->pipeline_stat
.reg
= reg
;
812 counter
->pipeline_stat
.numerator
= numerator
;
813 counter
->pipeline_stat
.denominator
= denominator
;
819 add_basic_stat_reg(struct gen_perf_query_info
*query
,
820 uint32_t reg
, const char *name
)
822 add_stat_reg(query
, reg
, 1, 1, name
, name
);
826 load_pipeline_statistic_metrics(struct gen_perf_config
*perf_cfg
,
827 const struct gen_device_info
*devinfo
)
829 struct gen_perf_query_info
*query
=
830 append_query_info(perf_cfg
, MAX_STAT_COUNTERS
);
832 query
->kind
= GEN_PERF_QUERY_TYPE_PIPELINE
;
833 query
->name
= "Pipeline Statistics Registers";
835 add_basic_stat_reg(query
, IA_VERTICES_COUNT
,
836 "N vertices submitted");
837 add_basic_stat_reg(query
, IA_PRIMITIVES_COUNT
,
838 "N primitives submitted");
839 add_basic_stat_reg(query
, VS_INVOCATION_COUNT
,
840 "N vertex shader invocations");
842 if (devinfo
->gen
== 6) {
843 add_stat_reg(query
, GEN6_SO_PRIM_STORAGE_NEEDED
, 1, 1,
844 "SO_PRIM_STORAGE_NEEDED",
845 "N geometry shader stream-out primitives (total)");
846 add_stat_reg(query
, GEN6_SO_NUM_PRIMS_WRITTEN
, 1, 1,
847 "SO_NUM_PRIMS_WRITTEN",
848 "N geometry shader stream-out primitives (written)");
850 add_stat_reg(query
, GEN7_SO_PRIM_STORAGE_NEEDED(0), 1, 1,
851 "SO_PRIM_STORAGE_NEEDED (Stream 0)",
852 "N stream-out (stream 0) primitives (total)");
853 add_stat_reg(query
, GEN7_SO_PRIM_STORAGE_NEEDED(1), 1, 1,
854 "SO_PRIM_STORAGE_NEEDED (Stream 1)",
855 "N stream-out (stream 1) primitives (total)");
856 add_stat_reg(query
, GEN7_SO_PRIM_STORAGE_NEEDED(2), 1, 1,
857 "SO_PRIM_STORAGE_NEEDED (Stream 2)",
858 "N stream-out (stream 2) primitives (total)");
859 add_stat_reg(query
, GEN7_SO_PRIM_STORAGE_NEEDED(3), 1, 1,
860 "SO_PRIM_STORAGE_NEEDED (Stream 3)",
861 "N stream-out (stream 3) primitives (total)");
862 add_stat_reg(query
, GEN7_SO_NUM_PRIMS_WRITTEN(0), 1, 1,
863 "SO_NUM_PRIMS_WRITTEN (Stream 0)",
864 "N stream-out (stream 0) primitives (written)");
865 add_stat_reg(query
, GEN7_SO_NUM_PRIMS_WRITTEN(1), 1, 1,
866 "SO_NUM_PRIMS_WRITTEN (Stream 1)",
867 "N stream-out (stream 1) primitives (written)");
868 add_stat_reg(query
, GEN7_SO_NUM_PRIMS_WRITTEN(2), 1, 1,
869 "SO_NUM_PRIMS_WRITTEN (Stream 2)",
870 "N stream-out (stream 2) primitives (written)");
871 add_stat_reg(query
, GEN7_SO_NUM_PRIMS_WRITTEN(3), 1, 1,
872 "SO_NUM_PRIMS_WRITTEN (Stream 3)",
873 "N stream-out (stream 3) primitives (written)");
876 add_basic_stat_reg(query
, HS_INVOCATION_COUNT
,
877 "N TCS shader invocations");
878 add_basic_stat_reg(query
, DS_INVOCATION_COUNT
,
879 "N TES shader invocations");
881 add_basic_stat_reg(query
, GS_INVOCATION_COUNT
,
882 "N geometry shader invocations");
883 add_basic_stat_reg(query
, GS_PRIMITIVES_COUNT
,
884 "N geometry shader primitives emitted");
886 add_basic_stat_reg(query
, CL_INVOCATION_COUNT
,
887 "N primitives entering clipping");
888 add_basic_stat_reg(query
, CL_PRIMITIVES_COUNT
,
889 "N primitives leaving clipping");
891 if (devinfo
->is_haswell
|| devinfo
->gen
== 8) {
892 add_stat_reg(query
, PS_INVOCATION_COUNT
, 1, 4,
893 "N fragment shader invocations",
894 "N fragment shader invocations");
896 add_basic_stat_reg(query
, PS_INVOCATION_COUNT
,
897 "N fragment shader invocations");
900 add_basic_stat_reg(query
, PS_DEPTH_COUNT
,
901 "N z-pass fragments");
903 if (devinfo
->gen
>= 7) {
904 add_basic_stat_reg(query
, CS_INVOCATION_COUNT
,
905 "N compute shader invocations");
908 query
->data_size
= sizeof(uint64_t) * query
->n_counters
;
912 load_oa_metrics(struct gen_perf_config
*perf
, int fd
,
913 const struct gen_device_info
*devinfo
)
915 perf_register_oa_queries_t oa_register
= get_register_queries_function(devinfo
);
916 bool i915_perf_oa_available
= false;
919 perf
->i915_query_supported
= i915_query_perf_config_supported(perf
, fd
);
921 /* The existence of this sysctl parameter implies the kernel supports
922 * the i915 perf interface.
924 if (stat("/proc/sys/dev/i915/perf_stream_paranoid", &sb
) == 0) {
926 /* If _paranoid == 1 then on Gen8+ we won't be able to access OA
927 * metrics unless running as root.
929 if (devinfo
->is_haswell
)
930 i915_perf_oa_available
= true;
932 uint64_t paranoid
= 1;
934 read_file_uint64("/proc/sys/dev/i915/perf_stream_paranoid", ¶noid
);
936 if (paranoid
== 0 || geteuid() == 0)
937 i915_perf_oa_available
= true;
941 if (!i915_perf_oa_available
||
943 !get_sysfs_dev_dir(perf
, fd
) ||
944 !init_oa_sys_vars(perf
, devinfo
))
947 perf
->oa_metrics_table
=
948 _mesa_hash_table_create(perf
, _mesa_key_hash_string
,
949 _mesa_key_string_equal
);
951 /* Index all the metric sets mesa knows about before looking to see what
952 * the kernel is advertising.
956 if (likely((INTEL_DEBUG
& DEBUG_NO_OACONFIG
) == 0) &&
957 kernel_has_dynamic_config_support(perf
, fd
))
958 init_oa_configs(perf
, fd
);
960 enumerate_sysfs_metrics(perf
);
965 struct gen_perf_registers
*
966 gen_perf_load_configuration(struct gen_perf_config
*perf_cfg
, int fd
, const char *guid
)
968 if (!perf_cfg
->i915_query_supported
)
971 struct drm_i915_perf_oa_config i915_config
= { 0, };
972 if (!i915_query_perf_config_data(perf_cfg
, fd
, guid
, &i915_config
))
975 struct gen_perf_registers
*config
= rzalloc(NULL
, struct gen_perf_registers
);
976 config
->n_flex_regs
= i915_config
.n_flex_regs
;
977 config
->flex_regs
= rzalloc_array(config
, struct gen_perf_query_register_prog
, config
->n_flex_regs
);
978 config
->n_mux_regs
= i915_config
.n_mux_regs
;
979 config
->mux_regs
= rzalloc_array(config
, struct gen_perf_query_register_prog
, config
->n_mux_regs
);
980 config
->n_b_counter_regs
= i915_config
.n_boolean_regs
;
981 config
->b_counter_regs
= rzalloc_array(config
, struct gen_perf_query_register_prog
, config
->n_b_counter_regs
);
984 * struct gen_perf_query_register_prog maps exactly to the tuple of
985 * (register offset, register value) returned by the i915.
987 i915_config
.flex_regs_ptr
= to_user_pointer(config
->flex_regs
);
988 i915_config
.mux_regs_ptr
= to_user_pointer(config
->mux_regs
);
989 i915_config
.boolean_regs_ptr
= to_user_pointer(config
->b_counter_regs
);
990 if (!i915_query_perf_config_data(perf_cfg
, fd
, guid
, &i915_config
)) {
999 gen_perf_store_configuration(struct gen_perf_config
*perf_cfg
, int fd
,
1000 const struct gen_perf_registers
*config
,
1004 return i915_add_config(perf_cfg
, fd
, config
, guid
);
1006 struct mesa_sha1 sha1_ctx
;
1007 _mesa_sha1_init(&sha1_ctx
);
1009 if (config
->flex_regs
) {
1010 _mesa_sha1_update(&sha1_ctx
, config
->flex_regs
,
1011 sizeof(config
->flex_regs
[0]) *
1012 config
->n_flex_regs
);
1014 if (config
->mux_regs
) {
1015 _mesa_sha1_update(&sha1_ctx
, config
->mux_regs
,
1016 sizeof(config
->mux_regs
[0]) *
1017 config
->n_mux_regs
);
1019 if (config
->b_counter_regs
) {
1020 _mesa_sha1_update(&sha1_ctx
, config
->b_counter_regs
,
1021 sizeof(config
->b_counter_regs
[0]) *
1022 config
->n_b_counter_regs
);
1026 _mesa_sha1_final(&sha1_ctx
, hash
);
1028 char formatted_hash
[41];
1029 _mesa_sha1_format(formatted_hash
, hash
);
1031 char generated_guid
[37];
1032 snprintf(generated_guid
, sizeof(generated_guid
),
1033 "%.8s-%.4s-%.4s-%.4s-%.12s",
1034 &formatted_hash
[0], &formatted_hash
[8],
1035 &formatted_hash
[8 + 4], &formatted_hash
[8 + 4 + 4],
1036 &formatted_hash
[8 + 4 + 4 + 4]);
1038 /* Check if already present. */
1040 if (gen_perf_load_metric_id(perf_cfg
, generated_guid
, &id
))
1043 return i915_add_config(perf_cfg
, fd
, config
, generated_guid
);
1046 /* Accumulate 32bits OA counters */
1048 accumulate_uint32(const uint32_t *report0
,
1049 const uint32_t *report1
,
1050 uint64_t *accumulator
)
1052 *accumulator
+= (uint32_t)(*report1
- *report0
);
1055 /* Accumulate 40bits OA counters */
1057 accumulate_uint40(int a_index
,
1058 const uint32_t *report0
,
1059 const uint32_t *report1
,
1060 uint64_t *accumulator
)
1062 const uint8_t *high_bytes0
= (uint8_t *)(report0
+ 40);
1063 const uint8_t *high_bytes1
= (uint8_t *)(report1
+ 40);
1064 uint64_t high0
= (uint64_t)(high_bytes0
[a_index
]) << 32;
1065 uint64_t high1
= (uint64_t)(high_bytes1
[a_index
]) << 32;
1066 uint64_t value0
= report0
[a_index
+ 4] | high0
;
1067 uint64_t value1
= report1
[a_index
+ 4] | high1
;
1070 if (value0
> value1
)
1071 delta
= (1ULL << 40) + value1
- value0
;
1073 delta
= value1
- value0
;
1075 *accumulator
+= delta
;
1079 gen8_read_report_clock_ratios(const uint32_t *report
,
1080 uint64_t *slice_freq_hz
,
1081 uint64_t *unslice_freq_hz
)
1083 /* The lower 16bits of the RPT_ID field of the OA reports contains a
1084 * snapshot of the bits coming from the RP_FREQ_NORMAL register and is
1085 * divided this way :
1087 * RPT_ID[31:25]: RP_FREQ_NORMAL[20:14] (low squashed_slice_clock_frequency)
1088 * RPT_ID[10:9]: RP_FREQ_NORMAL[22:21] (high squashed_slice_clock_frequency)
1089 * RPT_ID[8:0]: RP_FREQ_NORMAL[31:23] (squashed_unslice_clock_frequency)
1091 * RP_FREQ_NORMAL[31:23]: Software Unslice Ratio Request
1092 * Multiple of 33.33MHz 2xclk (16 MHz 1xclk)
1094 * RP_FREQ_NORMAL[22:14]: Software Slice Ratio Request
1095 * Multiple of 33.33MHz 2xclk (16 MHz 1xclk)
1098 uint32_t unslice_freq
= report
[0] & 0x1ff;
1099 uint32_t slice_freq_low
= (report
[0] >> 25) & 0x7f;
1100 uint32_t slice_freq_high
= (report
[0] >> 9) & 0x3;
1101 uint32_t slice_freq
= slice_freq_low
| (slice_freq_high
<< 7);
1103 *slice_freq_hz
= slice_freq
* 16666667ULL;
1104 *unslice_freq_hz
= unslice_freq
* 16666667ULL;
1108 gen_perf_query_result_read_frequencies(struct gen_perf_query_result
*result
,
1109 const struct gen_device_info
*devinfo
,
1110 const uint32_t *start
,
1111 const uint32_t *end
)
1113 /* Slice/Unslice frequency is only available in the OA reports when the
1114 * "Disable OA reports due to clock ratio change" field in
1115 * OA_DEBUG_REGISTER is set to 1. This is how the kernel programs this
1116 * global register (see drivers/gpu/drm/i915/i915_perf.c)
1118 * Documentation says this should be available on Gen9+ but experimentation
1119 * shows that Gen8 reports similar values, so we enable it there too.
1121 if (devinfo
->gen
< 8)
1124 gen8_read_report_clock_ratios(start
,
1125 &result
->slice_frequency
[0],
1126 &result
->unslice_frequency
[0]);
1127 gen8_read_report_clock_ratios(end
,
1128 &result
->slice_frequency
[1],
1129 &result
->unslice_frequency
[1]);
1133 gen_perf_query_result_accumulate(struct gen_perf_query_result
*result
,
1134 const struct gen_perf_query_info
*query
,
1135 const uint32_t *start
,
1136 const uint32_t *end
)
1140 result
->hw_id
= start
[2];
1141 result
->reports_accumulated
++;
1143 switch (query
->oa_format
) {
1144 case I915_OA_FORMAT_A32u40_A4u32_B8_C8
:
1145 accumulate_uint32(start
+ 1, end
+ 1, result
->accumulator
+ idx
++); /* timestamp */
1146 accumulate_uint32(start
+ 3, end
+ 3, result
->accumulator
+ idx
++); /* clock */
1148 /* 32x 40bit A counters... */
1149 for (i
= 0; i
< 32; i
++)
1150 accumulate_uint40(i
, start
, end
, result
->accumulator
+ idx
++);
1152 /* 4x 32bit A counters... */
1153 for (i
= 0; i
< 4; i
++)
1154 accumulate_uint32(start
+ 36 + i
, end
+ 36 + i
, result
->accumulator
+ idx
++);
1156 /* 8x 32bit B counters + 8x 32bit C counters... */
1157 for (i
= 0; i
< 16; i
++)
1158 accumulate_uint32(start
+ 48 + i
, end
+ 48 + i
, result
->accumulator
+ idx
++);
1161 case I915_OA_FORMAT_A45_B8_C8
:
1162 accumulate_uint32(start
+ 1, end
+ 1, result
->accumulator
); /* timestamp */
1164 for (i
= 0; i
< 61; i
++)
1165 accumulate_uint32(start
+ 3 + i
, end
+ 3 + i
, result
->accumulator
+ 1 + i
);
1169 unreachable("Can't accumulate OA counters in unknown format");
1175 gen_perf_query_result_clear(struct gen_perf_query_result
*result
)
1177 memset(result
, 0, sizeof(*result
));
1178 result
->hw_id
= 0xffffffff; /* invalid */
1182 register_mdapi_statistic_query(struct gen_perf_config
*perf_cfg
,
1183 const struct gen_device_info
*devinfo
)
1185 if (!(devinfo
->gen
>= 7 && devinfo
->gen
<= 11))
1188 struct gen_perf_query_info
*query
=
1189 append_query_info(perf_cfg
, MAX_STAT_COUNTERS
);
1191 query
->kind
= GEN_PERF_QUERY_TYPE_PIPELINE
;
1192 query
->name
= "Intel_Raw_Pipeline_Statistics_Query";
1194 /* The order has to match mdapi_pipeline_metrics. */
1195 add_basic_stat_reg(query
, IA_VERTICES_COUNT
,
1196 "N vertices submitted");
1197 add_basic_stat_reg(query
, IA_PRIMITIVES_COUNT
,
1198 "N primitives submitted");
1199 add_basic_stat_reg(query
, VS_INVOCATION_COUNT
,
1200 "N vertex shader invocations");
1201 add_basic_stat_reg(query
, GS_INVOCATION_COUNT
,
1202 "N geometry shader invocations");
1203 add_basic_stat_reg(query
, GS_PRIMITIVES_COUNT
,
1204 "N geometry shader primitives emitted");
1205 add_basic_stat_reg(query
, CL_INVOCATION_COUNT
,
1206 "N primitives entering clipping");
1207 add_basic_stat_reg(query
, CL_PRIMITIVES_COUNT
,
1208 "N primitives leaving clipping");
1209 if (devinfo
->is_haswell
|| devinfo
->gen
== 8) {
1210 add_stat_reg(query
, PS_INVOCATION_COUNT
, 1, 4,
1211 "N fragment shader invocations",
1212 "N fragment shader invocations");
1214 add_basic_stat_reg(query
, PS_INVOCATION_COUNT
,
1215 "N fragment shader invocations");
1217 add_basic_stat_reg(query
, HS_INVOCATION_COUNT
,
1218 "N TCS shader invocations");
1219 add_basic_stat_reg(query
, DS_INVOCATION_COUNT
,
1220 "N TES shader invocations");
1221 if (devinfo
->gen
>= 7) {
1222 add_basic_stat_reg(query
, CS_INVOCATION_COUNT
,
1223 "N compute shader invocations");
1226 if (devinfo
->gen
>= 10) {
1227 /* Reuse existing CS invocation register until we can expose this new
1230 add_basic_stat_reg(query
, CS_INVOCATION_COUNT
,
1234 query
->data_size
= sizeof(uint64_t) * query
->n_counters
;
1238 fill_mdapi_perf_query_counter(struct gen_perf_query_info
*query
,
1240 uint32_t data_offset
,
1242 enum gen_perf_counter_data_type data_type
)
1244 struct gen_perf_query_counter
*counter
= &query
->counters
[query
->n_counters
];
1246 assert(query
->n_counters
<= query
->max_counters
);
1248 counter
->name
= name
;
1249 counter
->desc
= "Raw counter value";
1250 counter
->type
= GEN_PERF_COUNTER_TYPE_RAW
;
1251 counter
->data_type
= data_type
;
1252 counter
->offset
= data_offset
;
1254 query
->n_counters
++;
1256 assert(counter
->offset
+ gen_perf_query_counter_get_size(counter
) <= query
->data_size
);
1259 #define MDAPI_QUERY_ADD_COUNTER(query, struct_name, field_name, type_name) \
1260 fill_mdapi_perf_query_counter(query, #field_name, \
1261 (uint8_t *) &struct_name.field_name - \
1262 (uint8_t *) &struct_name, \
1263 sizeof(struct_name.field_name), \
1264 GEN_PERF_COUNTER_DATA_TYPE_##type_name)
1265 #define MDAPI_QUERY_ADD_ARRAY_COUNTER(ctx, query, struct_name, field_name, idx, type_name) \
1266 fill_mdapi_perf_query_counter(query, \
1267 ralloc_asprintf(ctx, "%s%i", #field_name, idx), \
1268 (uint8_t *) &struct_name.field_name[idx] - \
1269 (uint8_t *) &struct_name, \
1270 sizeof(struct_name.field_name[0]), \
1271 GEN_PERF_COUNTER_DATA_TYPE_##type_name)
1274 register_mdapi_oa_query(const struct gen_device_info
*devinfo
,
1275 struct gen_perf_config
*perf
)
1277 struct gen_perf_query_info
*query
= NULL
;
1279 /* MDAPI requires different structures for pretty much every generation
1280 * (right now we have definitions for gen 7 to 11).
1282 if (!(devinfo
->gen
>= 7 && devinfo
->gen
<= 11))
1285 switch (devinfo
->gen
) {
1287 query
= append_query_info(perf
, 1 + 45 + 16 + 7);
1288 query
->oa_format
= I915_OA_FORMAT_A45_B8_C8
;
1290 struct gen7_mdapi_metrics metric_data
;
1291 query
->data_size
= sizeof(metric_data
);
1293 MDAPI_QUERY_ADD_COUNTER(query
, metric_data
, TotalTime
, UINT64
);
1294 for (int i
= 0; i
< ARRAY_SIZE(metric_data
.ACounters
); i
++) {
1295 MDAPI_QUERY_ADD_ARRAY_COUNTER(perf
->queries
, query
,
1296 metric_data
, ACounters
, i
, UINT64
);
1298 for (int i
= 0; i
< ARRAY_SIZE(metric_data
.NOACounters
); i
++) {
1299 MDAPI_QUERY_ADD_ARRAY_COUNTER(perf
->queries
, query
,
1300 metric_data
, NOACounters
, i
, UINT64
);
1302 MDAPI_QUERY_ADD_COUNTER(query
, metric_data
, PerfCounter1
, UINT64
);
1303 MDAPI_QUERY_ADD_COUNTER(query
, metric_data
, PerfCounter2
, UINT64
);
1304 MDAPI_QUERY_ADD_COUNTER(query
, metric_data
, SplitOccured
, BOOL32
);
1305 MDAPI_QUERY_ADD_COUNTER(query
, metric_data
, CoreFrequencyChanged
, BOOL32
);
1306 MDAPI_QUERY_ADD_COUNTER(query
, metric_data
, CoreFrequency
, UINT64
);
1307 MDAPI_QUERY_ADD_COUNTER(query
, metric_data
, ReportId
, UINT32
);
1308 MDAPI_QUERY_ADD_COUNTER(query
, metric_data
, ReportsCount
, UINT32
);
1312 query
= append_query_info(perf
, 2 + 36 + 16 + 16);
1313 query
->oa_format
= I915_OA_FORMAT_A32u40_A4u32_B8_C8
;
1315 struct gen8_mdapi_metrics metric_data
;
1316 query
->data_size
= sizeof(metric_data
);
1318 MDAPI_QUERY_ADD_COUNTER(query
, metric_data
, TotalTime
, UINT64
);
1319 MDAPI_QUERY_ADD_COUNTER(query
, metric_data
, GPUTicks
, UINT64
);
1320 for (int i
= 0; i
< ARRAY_SIZE(metric_data
.OaCntr
); i
++) {
1321 MDAPI_QUERY_ADD_ARRAY_COUNTER(perf
->queries
, query
,
1322 metric_data
, OaCntr
, i
, UINT64
);
1324 for (int i
= 0; i
< ARRAY_SIZE(metric_data
.NoaCntr
); i
++) {
1325 MDAPI_QUERY_ADD_ARRAY_COUNTER(perf
->queries
, query
,
1326 metric_data
, NoaCntr
, i
, UINT64
);
1328 MDAPI_QUERY_ADD_COUNTER(query
, metric_data
, BeginTimestamp
, UINT64
);
1329 MDAPI_QUERY_ADD_COUNTER(query
, metric_data
, Reserved1
, UINT64
);
1330 MDAPI_QUERY_ADD_COUNTER(query
, metric_data
, Reserved2
, UINT64
);
1331 MDAPI_QUERY_ADD_COUNTER(query
, metric_data
, Reserved3
, UINT32
);
1332 MDAPI_QUERY_ADD_COUNTER(query
, metric_data
, OverrunOccured
, BOOL32
);
1333 MDAPI_QUERY_ADD_COUNTER(query
, metric_data
, MarkerUser
, UINT64
);
1334 MDAPI_QUERY_ADD_COUNTER(query
, metric_data
, MarkerDriver
, UINT64
);
1335 MDAPI_QUERY_ADD_COUNTER(query
, metric_data
, SliceFrequency
, UINT64
);
1336 MDAPI_QUERY_ADD_COUNTER(query
, metric_data
, UnsliceFrequency
, UINT64
);
1337 MDAPI_QUERY_ADD_COUNTER(query
, metric_data
, PerfCounter1
, UINT64
);
1338 MDAPI_QUERY_ADD_COUNTER(query
, metric_data
, PerfCounter2
, UINT64
);
1339 MDAPI_QUERY_ADD_COUNTER(query
, metric_data
, SplitOccured
, BOOL32
);
1340 MDAPI_QUERY_ADD_COUNTER(query
, metric_data
, CoreFrequencyChanged
, BOOL32
);
1341 MDAPI_QUERY_ADD_COUNTER(query
, metric_data
, CoreFrequency
, UINT64
);
1342 MDAPI_QUERY_ADD_COUNTER(query
, metric_data
, ReportId
, UINT32
);
1343 MDAPI_QUERY_ADD_COUNTER(query
, metric_data
, ReportsCount
, UINT32
);
1349 query
= append_query_info(perf
, 2 + 36 + 16 + 16 + 16 + 2);
1350 query
->oa_format
= I915_OA_FORMAT_A32u40_A4u32_B8_C8
;
1352 struct gen9_mdapi_metrics metric_data
;
1353 query
->data_size
= sizeof(metric_data
);
1355 MDAPI_QUERY_ADD_COUNTER(query
, metric_data
, TotalTime
, UINT64
);
1356 MDAPI_QUERY_ADD_COUNTER(query
, metric_data
, GPUTicks
, UINT64
);
1357 for (int i
= 0; i
< ARRAY_SIZE(metric_data
.OaCntr
); i
++) {
1358 MDAPI_QUERY_ADD_ARRAY_COUNTER(perf
->queries
, query
,
1359 metric_data
, OaCntr
, i
, UINT64
);
1361 for (int i
= 0; i
< ARRAY_SIZE(metric_data
.NoaCntr
); i
++) {
1362 MDAPI_QUERY_ADD_ARRAY_COUNTER(perf
->queries
, query
,
1363 metric_data
, NoaCntr
, i
, UINT64
);
1365 MDAPI_QUERY_ADD_COUNTER(query
, metric_data
, BeginTimestamp
, UINT64
);
1366 MDAPI_QUERY_ADD_COUNTER(query
, metric_data
, Reserved1
, UINT64
);
1367 MDAPI_QUERY_ADD_COUNTER(query
, metric_data
, Reserved2
, UINT64
);
1368 MDAPI_QUERY_ADD_COUNTER(query
, metric_data
, Reserved3
, UINT32
);
1369 MDAPI_QUERY_ADD_COUNTER(query
, metric_data
, OverrunOccured
, BOOL32
);
1370 MDAPI_QUERY_ADD_COUNTER(query
, metric_data
, MarkerUser
, UINT64
);
1371 MDAPI_QUERY_ADD_COUNTER(query
, metric_data
, MarkerDriver
, UINT64
);
1372 MDAPI_QUERY_ADD_COUNTER(query
, metric_data
, SliceFrequency
, UINT64
);
1373 MDAPI_QUERY_ADD_COUNTER(query
, metric_data
, UnsliceFrequency
, UINT64
);
1374 MDAPI_QUERY_ADD_COUNTER(query
, metric_data
, PerfCounter1
, UINT64
);
1375 MDAPI_QUERY_ADD_COUNTER(query
, metric_data
, PerfCounter2
, UINT64
);
1376 MDAPI_QUERY_ADD_COUNTER(query
, metric_data
, SplitOccured
, BOOL32
);
1377 MDAPI_QUERY_ADD_COUNTER(query
, metric_data
, CoreFrequencyChanged
, BOOL32
);
1378 MDAPI_QUERY_ADD_COUNTER(query
, metric_data
, CoreFrequency
, UINT64
);
1379 MDAPI_QUERY_ADD_COUNTER(query
, metric_data
, ReportId
, UINT32
);
1380 MDAPI_QUERY_ADD_COUNTER(query
, metric_data
, ReportsCount
, UINT32
);
1381 for (int i
= 0; i
< ARRAY_SIZE(metric_data
.UserCntr
); i
++) {
1382 MDAPI_QUERY_ADD_ARRAY_COUNTER(perf
->queries
, query
,
1383 metric_data
, UserCntr
, i
, UINT64
);
1385 MDAPI_QUERY_ADD_COUNTER(query
, metric_data
, UserCntrCfgId
, UINT32
);
1386 MDAPI_QUERY_ADD_COUNTER(query
, metric_data
, Reserved4
, UINT32
);
1390 unreachable("Unsupported gen");
1394 query
->kind
= GEN_PERF_QUERY_TYPE_RAW
;
1395 query
->name
= "Intel_Raw_Hardware_Counters_Set_0_Query";
1396 query
->guid
= GEN_PERF_QUERY_GUID_MDAPI
;
1399 /* Accumulation buffer offsets copied from an actual query... */
1400 const struct gen_perf_query_info
*copy_query
=
1403 query
->gpu_time_offset
= copy_query
->gpu_time_offset
;
1404 query
->gpu_clock_offset
= copy_query
->gpu_clock_offset
;
1405 query
->a_offset
= copy_query
->a_offset
;
1406 query
->b_offset
= copy_query
->b_offset
;
1407 query
->c_offset
= copy_query
->c_offset
;
1412 get_metric_id(struct gen_perf_config
*perf
,
1413 const struct gen_perf_query_info
*query
)
1415 /* These queries are know not to ever change, their config ID has been
1416 * loaded upon the first query creation. No need to look them up again.
1418 if (query
->kind
== GEN_PERF_QUERY_TYPE_OA
)
1419 return query
->oa_metrics_set_id
;
1421 assert(query
->kind
== GEN_PERF_QUERY_TYPE_RAW
);
1423 /* Raw queries can be reprogrammed up by an external application/library.
1424 * When a raw query is used for the first time it's id is set to a value !=
1425 * 0. When it stops being used the id returns to 0. No need to reload the
1426 * ID when it's already loaded.
1428 if (query
->oa_metrics_set_id
!= 0) {
1429 DBG("Raw query '%s' guid=%s using cached ID: %"PRIu64
"\n",
1430 query
->name
, query
->guid
, query
->oa_metrics_set_id
);
1431 return query
->oa_metrics_set_id
;
1434 struct gen_perf_query_info
*raw_query
= (struct gen_perf_query_info
*)query
;
1435 if (!gen_perf_load_metric_id(perf
, query
->guid
,
1436 &raw_query
->oa_metrics_set_id
)) {
1437 DBG("Unable to read query guid=%s ID, falling back to test config\n", query
->guid
);
1438 raw_query
->oa_metrics_set_id
= 1ULL;
1440 DBG("Raw query '%s'guid=%s loaded ID: %"PRIu64
"\n",
1441 query
->name
, query
->guid
, query
->oa_metrics_set_id
);
1443 return query
->oa_metrics_set_id
;
1446 static struct oa_sample_buf
*
1447 get_free_sample_buf(struct gen_perf_context
*perf_ctx
)
1449 struct exec_node
*node
= exec_list_pop_head(&perf_ctx
->free_sample_buffers
);
1450 struct oa_sample_buf
*buf
;
1453 buf
= exec_node_data(struct oa_sample_buf
, node
, link
);
1455 buf
= ralloc_size(perf_ctx
->perf
, sizeof(*buf
));
1457 exec_node_init(&buf
->link
);
1466 reap_old_sample_buffers(struct gen_perf_context
*perf_ctx
)
1468 struct exec_node
*tail_node
=
1469 exec_list_get_tail(&perf_ctx
->sample_buffers
);
1470 struct oa_sample_buf
*tail_buf
=
1471 exec_node_data(struct oa_sample_buf
, tail_node
, link
);
1473 /* Remove all old, unreferenced sample buffers walking forward from
1474 * the head of the list, except always leave at least one node in
1475 * the list so we always have a node to reference when we Begin
1478 foreach_list_typed_safe(struct oa_sample_buf
, buf
, link
,
1479 &perf_ctx
->sample_buffers
)
1481 if (buf
->refcount
== 0 && buf
!= tail_buf
) {
1482 exec_node_remove(&buf
->link
);
1483 exec_list_push_head(&perf_ctx
->free_sample_buffers
, &buf
->link
);
1490 free_sample_bufs(struct gen_perf_context
*perf_ctx
)
1492 foreach_list_typed_safe(struct oa_sample_buf
, buf
, link
,
1493 &perf_ctx
->free_sample_buffers
)
1496 exec_list_make_empty(&perf_ctx
->free_sample_buffers
);
1499 /******************************************************************************/
1502 * Emit MI_STORE_REGISTER_MEM commands to capture all of the
1503 * pipeline statistics for the performance query object.
1506 snapshot_statistics_registers(void *context
,
1507 struct gen_perf_config
*perf
,
1508 struct gen_perf_query_object
*obj
,
1509 uint32_t offset_in_bytes
)
1511 const struct gen_perf_query_info
*query
= obj
->queryinfo
;
1512 const int n_counters
= query
->n_counters
;
1514 for (int i
= 0; i
< n_counters
; i
++) {
1515 const struct gen_perf_query_counter
*counter
= &query
->counters
[i
];
1517 assert(counter
->data_type
== GEN_PERF_COUNTER_DATA_TYPE_UINT64
);
1519 perf
->vtbl
.store_register_mem64(context
, obj
->pipeline_stats
.bo
,
1520 counter
->pipeline_stat
.reg
,
1521 offset_in_bytes
+ i
* sizeof(uint64_t));
1526 gen_perf_close(struct gen_perf_context
*perfquery
,
1527 const struct gen_perf_query_info
*query
)
1529 if (perfquery
->oa_stream_fd
!= -1) {
1530 close(perfquery
->oa_stream_fd
);
1531 perfquery
->oa_stream_fd
= -1;
1533 if (query
->kind
== GEN_PERF_QUERY_TYPE_RAW
) {
1534 struct gen_perf_query_info
*raw_query
=
1535 (struct gen_perf_query_info
*) query
;
1536 raw_query
->oa_metrics_set_id
= 0;
1541 gen_perf_open(struct gen_perf_context
*perf_ctx
,
1544 int period_exponent
,
1548 uint64_t properties
[] = {
1549 /* Single context sampling */
1550 DRM_I915_PERF_PROP_CTX_HANDLE
, ctx_id
,
1552 /* Include OA reports in samples */
1553 DRM_I915_PERF_PROP_SAMPLE_OA
, true,
1555 /* OA unit configuration */
1556 DRM_I915_PERF_PROP_OA_METRICS_SET
, metrics_set_id
,
1557 DRM_I915_PERF_PROP_OA_FORMAT
, report_format
,
1558 DRM_I915_PERF_PROP_OA_EXPONENT
, period_exponent
,
1560 struct drm_i915_perf_open_param param
= {
1561 .flags
= I915_PERF_FLAG_FD_CLOEXEC
|
1562 I915_PERF_FLAG_FD_NONBLOCK
|
1563 I915_PERF_FLAG_DISABLED
,
1564 .num_properties
= ARRAY_SIZE(properties
) / 2,
1565 .properties_ptr
= (uintptr_t) properties
,
1567 int fd
= gen_ioctl(drm_fd
, DRM_IOCTL_I915_PERF_OPEN
, ¶m
);
1569 DBG("Error opening gen perf OA stream: %m\n");
1573 perf_ctx
->oa_stream_fd
= fd
;
1575 perf_ctx
->current_oa_metrics_set_id
= metrics_set_id
;
1576 perf_ctx
->current_oa_format
= report_format
;
1582 inc_n_users(struct gen_perf_context
*perf_ctx
)
1584 if (perf_ctx
->n_oa_users
== 0 &&
1585 gen_ioctl(perf_ctx
->oa_stream_fd
, I915_PERF_IOCTL_ENABLE
, 0) < 0)
1589 ++perf_ctx
->n_oa_users
;
1595 dec_n_users(struct gen_perf_context
*perf_ctx
)
1597 /* Disabling the i915 perf stream will effectively disable the OA
1598 * counters. Note it's important to be sure there are no outstanding
1599 * MI_RPC commands at this point since they could stall the CS
1600 * indefinitely once OACONTROL is disabled.
1602 --perf_ctx
->n_oa_users
;
1603 if (perf_ctx
->n_oa_users
== 0 &&
1604 gen_ioctl(perf_ctx
->oa_stream_fd
, I915_PERF_IOCTL_DISABLE
, 0) < 0)
1606 DBG("WARNING: Error disabling gen perf stream: %m\n");
1611 gen_perf_init_metrics(struct gen_perf_config
*perf_cfg
,
1612 const struct gen_device_info
*devinfo
,
1615 load_pipeline_statistic_metrics(perf_cfg
, devinfo
);
1616 register_mdapi_statistic_query(perf_cfg
, devinfo
);
1617 if (load_oa_metrics(perf_cfg
, drm_fd
, devinfo
))
1618 register_mdapi_oa_query(devinfo
, perf_cfg
);
1622 gen_perf_init_context(struct gen_perf_context
*perf_ctx
,
1623 struct gen_perf_config
*perf_cfg
,
1624 void * ctx
, /* driver context (eg, brw_context) */
1625 void * bufmgr
, /* eg brw_bufmgr */
1626 const struct gen_device_info
*devinfo
,
1630 perf_ctx
->perf
= perf_cfg
;
1631 perf_ctx
->ctx
= ctx
;
1632 perf_ctx
->bufmgr
= bufmgr
;
1633 perf_ctx
->drm_fd
= drm_fd
;
1634 perf_ctx
->hw_ctx
= hw_ctx
;
1635 perf_ctx
->devinfo
= devinfo
;
1637 perf_ctx
->unaccumulated
=
1638 ralloc_array(ctx
, struct gen_perf_query_object
*, 2);
1639 perf_ctx
->unaccumulated_elements
= 0;
1640 perf_ctx
->unaccumulated_array_size
= 2;
1642 exec_list_make_empty(&perf_ctx
->sample_buffers
);
1643 exec_list_make_empty(&perf_ctx
->free_sample_buffers
);
1645 /* It's convenient to guarantee that this linked list of sample
1646 * buffers is never empty so we add an empty head so when we
1647 * Begin an OA query we can always take a reference on a buffer
1650 struct oa_sample_buf
*buf
= get_free_sample_buf(perf_ctx
);
1651 exec_list_push_head(&perf_ctx
->sample_buffers
, &buf
->link
);
1653 perf_ctx
->oa_stream_fd
= -1;
1654 perf_ctx
->next_query_start_report_id
= 1000;
1658 * Add a query to the global list of "unaccumulated queries."
1660 * Queries are tracked here until all the associated OA reports have
1661 * been accumulated via accumulate_oa_reports() after the end
1662 * MI_REPORT_PERF_COUNT has landed in query->oa.bo.
1665 add_to_unaccumulated_query_list(struct gen_perf_context
*perf_ctx
,
1666 struct gen_perf_query_object
*obj
)
1668 if (perf_ctx
->unaccumulated_elements
>=
1669 perf_ctx
->unaccumulated_array_size
)
1671 perf_ctx
->unaccumulated_array_size
*= 1.5;
1672 perf_ctx
->unaccumulated
=
1673 reralloc(perf_ctx
->ctx
, perf_ctx
->unaccumulated
,
1674 struct gen_perf_query_object
*,
1675 perf_ctx
->unaccumulated_array_size
);
1678 perf_ctx
->unaccumulated
[perf_ctx
->unaccumulated_elements
++] = obj
;
1682 gen_perf_begin_query(struct gen_perf_context
*perf_ctx
,
1683 struct gen_perf_query_object
*query
)
1685 struct gen_perf_config
*perf_cfg
= perf_ctx
->perf
;
1686 const struct gen_perf_query_info
*queryinfo
= query
->queryinfo
;
1688 /* XXX: We have to consider that the command parser unit that parses batch
1689 * buffer commands and is used to capture begin/end counter snapshots isn't
1690 * implicitly synchronized with what's currently running across other GPU
1691 * units (such as the EUs running shaders) that the performance counters are
1694 * The intention of performance queries is to measure the work associated
1695 * with commands between the begin/end delimiters and so for that to be the
1696 * case we need to explicitly synchronize the parsing of commands to capture
1697 * Begin/End counter snapshots with what's running across other parts of the
1700 * When the command parser reaches a Begin marker it effectively needs to
1701 * drain everything currently running on the GPU until the hardware is idle
1702 * before capturing the first snapshot of counters - otherwise the results
1703 * would also be measuring the effects of earlier commands.
1705 * When the command parser reaches an End marker it needs to stall until
1706 * everything currently running on the GPU has finished before capturing the
1707 * end snapshot - otherwise the results won't be a complete representation
1710 * Theoretically there could be opportunities to minimize how much of the
1711 * GPU pipeline is drained, or that we stall for, when we know what specific
1712 * units the performance counters being queried relate to but we don't
1713 * currently attempt to be clever here.
1715 * Note: with our current simple approach here then for back-to-back queries
1716 * we will redundantly emit duplicate commands to synchronize the command
1717 * streamer with the rest of the GPU pipeline, but we assume that in HW the
1718 * second synchronization is effectively a NOOP.
1720 * N.B. The final results are based on deltas of counters between (inside)
1721 * Begin/End markers so even though the total wall clock time of the
1722 * workload is stretched by larger pipeline bubbles the bubbles themselves
1723 * are generally invisible to the query results. Whether that's a good or a
1724 * bad thing depends on the use case. For a lower real-time impact while
1725 * capturing metrics then periodic sampling may be a better choice than
1726 * INTEL_performance_query.
1729 * This is our Begin synchronization point to drain current work on the
1730 * GPU before we capture our first counter snapshot...
1732 perf_cfg
->vtbl
.emit_mi_flush(perf_ctx
->ctx
);
1734 switch (queryinfo
->kind
) {
1735 case GEN_PERF_QUERY_TYPE_OA
:
1736 case GEN_PERF_QUERY_TYPE_RAW
: {
1738 /* Opening an i915 perf stream implies exclusive access to the OA unit
1739 * which will generate counter reports for a specific counter set with a
1740 * specific layout/format so we can't begin any OA based queries that
1741 * require a different counter set or format unless we get an opportunity
1742 * to close the stream and open a new one...
1744 uint64_t metric_id
= get_metric_id(perf_ctx
->perf
, queryinfo
);
1746 if (perf_ctx
->oa_stream_fd
!= -1 &&
1747 perf_ctx
->current_oa_metrics_set_id
!= metric_id
) {
1749 if (perf_ctx
->n_oa_users
!= 0) {
1750 DBG("WARNING: Begin failed already using perf config=%i/%"PRIu64
"\n",
1751 perf_ctx
->current_oa_metrics_set_id
, metric_id
);
1754 gen_perf_close(perf_ctx
, queryinfo
);
1757 /* If the OA counters aren't already on, enable them. */
1758 if (perf_ctx
->oa_stream_fd
== -1) {
1759 const struct gen_device_info
*devinfo
= perf_ctx
->devinfo
;
1761 /* The period_exponent gives a sampling period as follows:
1762 * sample_period = timestamp_period * 2^(period_exponent + 1)
1764 * The timestamps increments every 80ns (HSW), ~52ns (GEN9LP) or
1767 * The counter overflow period is derived from the EuActive counter
1768 * which reads a counter that increments by the number of clock
1769 * cycles multiplied by the number of EUs. It can be calculated as:
1771 * 2^(number of bits in A counter) / (n_eus * max_gen_freq * 2)
1773 * (E.g. 40 EUs @ 1GHz = ~53ms)
1775 * We select a sampling period inferior to that overflow period to
1776 * ensure we cannot see more than 1 counter overflow, otherwise we
1777 * could loose information.
1780 int a_counter_in_bits
= 32;
1781 if (devinfo
->gen
>= 8)
1782 a_counter_in_bits
= 40;
1784 uint64_t overflow_period
= pow(2, a_counter_in_bits
) / (perf_cfg
->sys_vars
.n_eus
*
1785 /* drop 1GHz freq to have units in nanoseconds */
1788 DBG("A counter overflow period: %"PRIu64
"ns, %"PRIu64
"ms (n_eus=%"PRIu64
")\n",
1789 overflow_period
, overflow_period
/ 1000000ul, perf_cfg
->sys_vars
.n_eus
);
1791 int period_exponent
= 0;
1792 uint64_t prev_sample_period
, next_sample_period
;
1793 for (int e
= 0; e
< 30; e
++) {
1794 prev_sample_period
= 1000000000ull * pow(2, e
+ 1) / devinfo
->timestamp_frequency
;
1795 next_sample_period
= 1000000000ull * pow(2, e
+ 2) / devinfo
->timestamp_frequency
;
1797 /* Take the previous sampling period, lower than the overflow
1800 if (prev_sample_period
< overflow_period
&&
1801 next_sample_period
> overflow_period
)
1802 period_exponent
= e
+ 1;
1805 if (period_exponent
== 0) {
1806 DBG("WARNING: enable to find a sampling exponent\n");
1810 DBG("OA sampling exponent: %i ~= %"PRIu64
"ms\n", period_exponent
,
1811 prev_sample_period
/ 1000000ul);
1813 if (!gen_perf_open(perf_ctx
, metric_id
, queryinfo
->oa_format
,
1814 period_exponent
, perf_ctx
->drm_fd
,
1818 assert(perf_ctx
->current_oa_metrics_set_id
== metric_id
&&
1819 perf_ctx
->current_oa_format
== queryinfo
->oa_format
);
1822 if (!inc_n_users(perf_ctx
)) {
1823 DBG("WARNING: Error enabling i915 perf stream: %m\n");
1828 perf_cfg
->vtbl
.bo_unreference(query
->oa
.bo
);
1829 query
->oa
.bo
= NULL
;
1832 query
->oa
.bo
= perf_cfg
->vtbl
.bo_alloc(perf_ctx
->bufmgr
,
1833 "perf. query OA MI_RPC bo",
1836 /* Pre-filling the BO helps debug whether writes landed. */
1837 void *map
= perf_cfg
->vtbl
.bo_map(perf_ctx
->ctx
, query
->oa
.bo
, MAP_WRITE
);
1838 memset(map
, 0x80, MI_RPC_BO_SIZE
);
1839 perf_cfg
->vtbl
.bo_unmap(query
->oa
.bo
);
1842 query
->oa
.begin_report_id
= perf_ctx
->next_query_start_report_id
;
1843 perf_ctx
->next_query_start_report_id
+= 2;
1845 /* We flush the batchbuffer here to minimize the chances that MI_RPC
1846 * delimiting commands end up in different batchbuffers. If that's the
1847 * case, the measurement will include the time it takes for the kernel
1848 * scheduler to load a new request into the hardware. This is manifested in
1849 * tools like frameretrace by spikes in the "GPU Core Clocks" counter.
1851 perf_cfg
->vtbl
.batchbuffer_flush(perf_ctx
->ctx
, __FILE__
, __LINE__
);
1853 /* Take a starting OA counter snapshot. */
1854 perf_cfg
->vtbl
.emit_mi_report_perf_count(perf_ctx
->ctx
, query
->oa
.bo
, 0,
1855 query
->oa
.begin_report_id
);
1856 perf_cfg
->vtbl
.capture_frequency_stat_register(perf_ctx
->ctx
, query
->oa
.bo
,
1857 MI_FREQ_START_OFFSET_BYTES
);
1859 ++perf_ctx
->n_active_oa_queries
;
1861 /* No already-buffered samples can possibly be associated with this query
1862 * so create a marker within the list of sample buffers enabling us to
1863 * easily ignore earlier samples when processing this query after
1866 assert(!exec_list_is_empty(&perf_ctx
->sample_buffers
));
1867 query
->oa
.samples_head
= exec_list_get_tail(&perf_ctx
->sample_buffers
);
1869 struct oa_sample_buf
*buf
=
1870 exec_node_data(struct oa_sample_buf
, query
->oa
.samples_head
, link
);
1872 /* This reference will ensure that future/following sample
1873 * buffers (that may relate to this query) can't be freed until
1874 * this drops to zero.
1878 gen_perf_query_result_clear(&query
->oa
.result
);
1879 query
->oa
.results_accumulated
= false;
1881 add_to_unaccumulated_query_list(perf_ctx
, query
);
1885 case GEN_PERF_QUERY_TYPE_PIPELINE
:
1886 if (query
->pipeline_stats
.bo
) {
1887 perf_cfg
->vtbl
.bo_unreference(query
->pipeline_stats
.bo
);
1888 query
->pipeline_stats
.bo
= NULL
;
1891 query
->pipeline_stats
.bo
=
1892 perf_cfg
->vtbl
.bo_alloc(perf_ctx
->bufmgr
,
1893 "perf. query pipeline stats bo",
1896 /* Take starting snapshots. */
1897 snapshot_statistics_registers(perf_ctx
->ctx
, perf_cfg
, query
, 0);
1899 ++perf_ctx
->n_active_pipeline_stats_queries
;
1903 unreachable("Unknown query type");
1911 gen_perf_end_query(struct gen_perf_context
*perf_ctx
,
1912 struct gen_perf_query_object
*query
)
1914 struct gen_perf_config
*perf_cfg
= perf_ctx
->perf
;
1916 /* Ensure that the work associated with the queried commands will have
1917 * finished before taking our query end counter readings.
1919 * For more details see comment in brw_begin_perf_query for
1920 * corresponding flush.
1922 perf_cfg
->vtbl
.emit_mi_flush(perf_ctx
->ctx
);
1924 switch (query
->queryinfo
->kind
) {
1925 case GEN_PERF_QUERY_TYPE_OA
:
1926 case GEN_PERF_QUERY_TYPE_RAW
:
1928 /* NB: It's possible that the query will have already been marked
1929 * as 'accumulated' if an error was seen while reading samples
1930 * from perf. In this case we mustn't try and emit a closing
1931 * MI_RPC command in case the OA unit has already been disabled
1933 if (!query
->oa
.results_accumulated
) {
1934 /* Take an ending OA counter snapshot. */
1935 perf_cfg
->vtbl
.capture_frequency_stat_register(perf_ctx
->ctx
, query
->oa
.bo
,
1936 MI_FREQ_END_OFFSET_BYTES
);
1937 perf_cfg
->vtbl
.emit_mi_report_perf_count(perf_ctx
->ctx
, query
->oa
.bo
,
1938 MI_RPC_BO_END_OFFSET_BYTES
,
1939 query
->oa
.begin_report_id
+ 1);
1942 --perf_ctx
->n_active_oa_queries
;
1944 /* NB: even though the query has now ended, it can't be accumulated
1945 * until the end MI_REPORT_PERF_COUNT snapshot has been written
1950 case GEN_PERF_QUERY_TYPE_PIPELINE
:
1951 snapshot_statistics_registers(perf_ctx
->ctx
, perf_cfg
, query
,
1952 STATS_BO_END_OFFSET_BYTES
);
1953 --perf_ctx
->n_active_pipeline_stats_queries
;
1957 unreachable("Unknown query type");
1963 OA_READ_STATUS_ERROR
,
1964 OA_READ_STATUS_UNFINISHED
,
1965 OA_READ_STATUS_FINISHED
,
1968 static enum OaReadStatus
1969 read_oa_samples_until(struct gen_perf_context
*perf_ctx
,
1970 uint32_t start_timestamp
,
1971 uint32_t end_timestamp
)
1973 struct exec_node
*tail_node
=
1974 exec_list_get_tail(&perf_ctx
->sample_buffers
);
1975 struct oa_sample_buf
*tail_buf
=
1976 exec_node_data(struct oa_sample_buf
, tail_node
, link
);
1977 uint32_t last_timestamp
= tail_buf
->last_timestamp
;
1980 struct oa_sample_buf
*buf
= get_free_sample_buf(perf_ctx
);
1984 while ((len
= read(perf_ctx
->oa_stream_fd
, buf
->buf
,
1985 sizeof(buf
->buf
))) < 0 && errno
== EINTR
)
1989 exec_list_push_tail(&perf_ctx
->free_sample_buffers
, &buf
->link
);
1992 if (errno
== EAGAIN
)
1993 return ((last_timestamp
- start_timestamp
) >=
1994 (end_timestamp
- start_timestamp
)) ?
1995 OA_READ_STATUS_FINISHED
:
1996 OA_READ_STATUS_UNFINISHED
;
1998 DBG("Error reading i915 perf samples: %m\n");
2001 DBG("Spurious EOF reading i915 perf samples\n");
2003 return OA_READ_STATUS_ERROR
;
2007 exec_list_push_tail(&perf_ctx
->sample_buffers
, &buf
->link
);
2009 /* Go through the reports and update the last timestamp. */
2011 while (offset
< buf
->len
) {
2012 const struct drm_i915_perf_record_header
*header
=
2013 (const struct drm_i915_perf_record_header
*) &buf
->buf
[offset
];
2014 uint32_t *report
= (uint32_t *) (header
+ 1);
2016 if (header
->type
== DRM_I915_PERF_RECORD_SAMPLE
)
2017 last_timestamp
= report
[1];
2019 offset
+= header
->size
;
2022 buf
->last_timestamp
= last_timestamp
;
2025 unreachable("not reached");
2026 return OA_READ_STATUS_ERROR
;
2030 * Try to read all the reports until either the delimiting timestamp
2031 * or an error arises.
2034 read_oa_samples_for_query(struct gen_perf_context
*perf_ctx
,
2035 struct gen_perf_query_object
*query
,
2036 void *current_batch
)
2041 struct gen_perf_config
*perf_cfg
= perf_ctx
->perf
;
2043 /* We need the MI_REPORT_PERF_COUNT to land before we can start
2045 assert(!perf_cfg
->vtbl
.batch_references(current_batch
, query
->oa
.bo
) &&
2046 !perf_cfg
->vtbl
.bo_busy(query
->oa
.bo
));
2048 /* Map the BO once here and let accumulate_oa_reports() unmap
2050 if (query
->oa
.map
== NULL
)
2051 query
->oa
.map
= perf_cfg
->vtbl
.bo_map(perf_ctx
->ctx
, query
->oa
.bo
, MAP_READ
);
2053 start
= last
= query
->oa
.map
;
2054 end
= query
->oa
.map
+ MI_RPC_BO_END_OFFSET_BYTES
;
2056 if (start
[0] != query
->oa
.begin_report_id
) {
2057 DBG("Spurious start report id=%"PRIu32
"\n", start
[0]);
2060 if (end
[0] != (query
->oa
.begin_report_id
+ 1)) {
2061 DBG("Spurious end report id=%"PRIu32
"\n", end
[0]);
2065 /* Read the reports until the end timestamp. */
2066 switch (read_oa_samples_until(perf_ctx
, start
[1], end
[1])) {
2067 case OA_READ_STATUS_ERROR
:
2068 /* Fallthrough and let accumulate_oa_reports() deal with the
2070 case OA_READ_STATUS_FINISHED
:
2072 case OA_READ_STATUS_UNFINISHED
:
2076 unreachable("invalid read status");
2081 gen_perf_wait_query(struct gen_perf_context
*perf_ctx
,
2082 struct gen_perf_query_object
*query
,
2083 void *current_batch
)
2085 struct gen_perf_config
*perf_cfg
= perf_ctx
->perf
;
2086 struct brw_bo
*bo
= NULL
;
2088 switch (query
->queryinfo
->kind
) {
2089 case GEN_PERF_QUERY_TYPE_OA
:
2090 case GEN_PERF_QUERY_TYPE_RAW
:
2094 case GEN_PERF_QUERY_TYPE_PIPELINE
:
2095 bo
= query
->pipeline_stats
.bo
;
2099 unreachable("Unknown query type");
2106 /* If the current batch references our results bo then we need to
2109 if (perf_cfg
->vtbl
.batch_references(current_batch
, bo
))
2110 perf_cfg
->vtbl
.batchbuffer_flush(perf_ctx
->ctx
, __FILE__
, __LINE__
);
2112 perf_cfg
->vtbl
.bo_wait_rendering(bo
);
2114 /* Due to a race condition between the OA unit signaling report
2115 * availability and the report actually being written into memory,
2116 * we need to wait for all the reports to come in before we can
2119 if (query
->queryinfo
->kind
== GEN_PERF_QUERY_TYPE_OA
||
2120 query
->queryinfo
->kind
== GEN_PERF_QUERY_TYPE_RAW
) {
2121 while (!read_oa_samples_for_query(perf_ctx
, query
, current_batch
))
2127 gen_perf_is_query_ready(struct gen_perf_context
*perf_ctx
,
2128 struct gen_perf_query_object
*query
,
2129 void *current_batch
)
2131 struct gen_perf_config
*perf_cfg
= perf_ctx
->perf
;
2133 switch (query
->queryinfo
->kind
) {
2134 case GEN_PERF_QUERY_TYPE_OA
:
2135 case GEN_PERF_QUERY_TYPE_RAW
:
2136 return (query
->oa
.results_accumulated
||
2138 !perf_cfg
->vtbl
.batch_references(current_batch
, query
->oa
.bo
) &&
2139 !perf_cfg
->vtbl
.bo_busy(query
->oa
.bo
) &&
2140 read_oa_samples_for_query(perf_ctx
, query
, current_batch
)));
2141 case GEN_PERF_QUERY_TYPE_PIPELINE
:
2142 return (query
->pipeline_stats
.bo
&&
2143 !perf_cfg
->vtbl
.batch_references(current_batch
, query
->pipeline_stats
.bo
) &&
2144 !perf_cfg
->vtbl
.bo_busy(query
->pipeline_stats
.bo
));
2147 unreachable("Unknown query type");
2155 * Remove a query from the global list of unaccumulated queries once
2156 * after successfully accumulating the OA reports associated with the
2157 * query in accumulate_oa_reports() or when discarding unwanted query
2161 drop_from_unaccumulated_query_list(struct gen_perf_context
*perf_ctx
,
2162 struct gen_perf_query_object
*query
)
2164 for (int i
= 0; i
< perf_ctx
->unaccumulated_elements
; i
++) {
2165 if (perf_ctx
->unaccumulated
[i
] == query
) {
2166 int last_elt
= --perf_ctx
->unaccumulated_elements
;
2169 perf_ctx
->unaccumulated
[i
] = NULL
;
2171 perf_ctx
->unaccumulated
[i
] =
2172 perf_ctx
->unaccumulated
[last_elt
];
2179 /* Drop our samples_head reference so that associated periodic
2180 * sample data buffers can potentially be reaped if they aren't
2181 * referenced by any other queries...
2184 struct oa_sample_buf
*buf
=
2185 exec_node_data(struct oa_sample_buf
, query
->oa
.samples_head
, link
);
2187 assert(buf
->refcount
> 0);
2190 query
->oa
.samples_head
= NULL
;
2192 reap_old_sample_buffers(perf_ctx
);
2195 /* In general if we see anything spurious while accumulating results,
2196 * we don't try and continue accumulating the current query, hoping
2197 * for the best, we scrap anything outstanding, and then hope for the
2198 * best with new queries.
2201 discard_all_queries(struct gen_perf_context
*perf_ctx
)
2203 while (perf_ctx
->unaccumulated_elements
) {
2204 struct gen_perf_query_object
*query
= perf_ctx
->unaccumulated
[0];
2206 query
->oa
.results_accumulated
= true;
2207 drop_from_unaccumulated_query_list(perf_ctx
, query
);
2209 dec_n_users(perf_ctx
);
2214 * Accumulate raw OA counter values based on deltas between pairs of
2217 * Accumulation starts from the first report captured via
2218 * MI_REPORT_PERF_COUNT (MI_RPC) by brw_begin_perf_query() until the
2219 * last MI_RPC report requested by brw_end_perf_query(). Between these
2220 * two reports there may also some number of periodically sampled OA
2221 * reports collected via the i915 perf interface - depending on the
2222 * duration of the query.
2224 * These periodic snapshots help to ensure we handle counter overflow
2225 * correctly by being frequent enough to ensure we don't miss multiple
2226 * overflows of a counter between snapshots. For Gen8+ the i915 perf
2227 * snapshots provide the extra context-switch reports that let us
2228 * subtract out the progress of counters associated with other
2229 * contexts running on the system.
2232 accumulate_oa_reports(struct gen_perf_context
*perf_ctx
,
2233 struct gen_perf_query_object
*query
)
2235 const struct gen_device_info
*devinfo
= perf_ctx
->devinfo
;
2239 struct exec_node
*first_samples_node
;
2241 int out_duration
= 0;
2243 assert(query
->oa
.map
!= NULL
);
2245 start
= last
= query
->oa
.map
;
2246 end
= query
->oa
.map
+ MI_RPC_BO_END_OFFSET_BYTES
;
2248 if (start
[0] != query
->oa
.begin_report_id
) {
2249 DBG("Spurious start report id=%"PRIu32
"\n", start
[0]);
2252 if (end
[0] != (query
->oa
.begin_report_id
+ 1)) {
2253 DBG("Spurious end report id=%"PRIu32
"\n", end
[0]);
2257 /* See if we have any periodic reports to accumulate too... */
2259 /* N.B. The oa.samples_head was set when the query began and
2260 * pointed to the tail of the perf_ctx->sample_buffers list at
2261 * the time the query started. Since the buffer existed before the
2262 * first MI_REPORT_PERF_COUNT command was emitted we therefore know
2263 * that no data in this particular node's buffer can possibly be
2264 * associated with the query - so skip ahead one...
2266 first_samples_node
= query
->oa
.samples_head
->next
;
2268 foreach_list_typed_from(struct oa_sample_buf
, buf
, link
,
2269 &perf_ctx
.sample_buffers
,
2274 while (offset
< buf
->len
) {
2275 const struct drm_i915_perf_record_header
*header
=
2276 (const struct drm_i915_perf_record_header
*)(buf
->buf
+ offset
);
2278 assert(header
->size
!= 0);
2279 assert(header
->size
<= buf
->len
);
2281 offset
+= header
->size
;
2283 switch (header
->type
) {
2284 case DRM_I915_PERF_RECORD_SAMPLE
: {
2285 uint32_t *report
= (uint32_t *)(header
+ 1);
2288 /* Ignore reports that come before the start marker.
2289 * (Note: takes care to allow overflow of 32bit timestamps)
2291 if (gen_device_info_timebase_scale(devinfo
,
2292 report
[1] - start
[1]) > 5000000000) {
2296 /* Ignore reports that come after the end marker.
2297 * (Note: takes care to allow overflow of 32bit timestamps)
2299 if (gen_device_info_timebase_scale(devinfo
,
2300 report
[1] - end
[1]) <= 5000000000) {
2304 /* For Gen8+ since the counters continue while other
2305 * contexts are running we need to discount any unrelated
2306 * deltas. The hardware automatically generates a report
2307 * on context switch which gives us a new reference point
2308 * to continuing adding deltas from.
2310 * For Haswell we can rely on the HW to stop the progress
2311 * of OA counters while any other context is acctive.
2313 if (devinfo
->gen
>= 8) {
2314 if (in_ctx
&& report
[2] != query
->oa
.result
.hw_id
) {
2315 DBG("i915 perf: Switch AWAY (observed by ID change)\n");
2318 } else if (in_ctx
== false && report
[2] == query
->oa
.result
.hw_id
) {
2319 DBG("i915 perf: Switch TO\n");
2322 /* From experimentation in IGT, we found that the OA unit
2323 * might label some report as "idle" (using an invalid
2324 * context ID), right after a report for a given context.
2325 * Deltas generated by those reports actually belong to the
2326 * previous context, even though they're not labelled as
2329 * We didn't *really* Switch AWAY in the case that we e.g.
2330 * saw a single periodic report while idle...
2332 if (out_duration
>= 1)
2334 } else if (in_ctx
) {
2335 assert(report
[2] == query
->oa
.result
.hw_id
);
2336 DBG("i915 perf: Continuation IN\n");
2338 assert(report
[2] != query
->oa
.result
.hw_id
);
2339 DBG("i915 perf: Continuation OUT\n");
2346 gen_perf_query_result_accumulate(&query
->oa
.result
,
2356 case DRM_I915_PERF_RECORD_OA_BUFFER_LOST
:
2357 DBG("i915 perf: OA error: all reports lost\n");
2359 case DRM_I915_PERF_RECORD_OA_REPORT_LOST
:
2360 DBG("i915 perf: OA report lost\n");
2368 gen_perf_query_result_accumulate(&query
->oa
.result
, query
->queryinfo
,
2371 query
->oa
.results_accumulated
= true;
2372 drop_from_unaccumulated_query_list(perf_ctx
, query
);
2373 dec_n_users(perf_ctx
);
2379 discard_all_queries(perf_ctx
);
2383 gen_perf_delete_query(struct gen_perf_context
*perf_ctx
,
2384 struct gen_perf_query_object
*query
)
2386 struct gen_perf_config
*perf_cfg
= perf_ctx
->perf
;
2388 /* We can assume that the frontend waits for a query to complete
2389 * before ever calling into here, so we don't have to worry about
2390 * deleting an in-flight query object.
2392 switch (query
->queryinfo
->kind
) {
2393 case GEN_PERF_QUERY_TYPE_OA
:
2394 case GEN_PERF_QUERY_TYPE_RAW
:
2396 if (!query
->oa
.results_accumulated
) {
2397 drop_from_unaccumulated_query_list(perf_ctx
, query
);
2398 dec_n_users(perf_ctx
);
2401 perf_cfg
->vtbl
.bo_unreference(query
->oa
.bo
);
2402 query
->oa
.bo
= NULL
;
2405 query
->oa
.results_accumulated
= false;
2408 case GEN_PERF_QUERY_TYPE_PIPELINE
:
2409 if (query
->pipeline_stats
.bo
) {
2410 perf_cfg
->vtbl
.bo_unreference(query
->pipeline_stats
.bo
);
2411 query
->pipeline_stats
.bo
= NULL
;
2416 unreachable("Unknown query type");
2420 /* As an indication that the INTEL_performance_query extension is no
2421 * longer in use, it's a good time to free our cache of sample
2422 * buffers and close any current i915-perf stream.
2424 if (--perf_ctx
->n_query_instances
== 0) {
2425 free_sample_bufs(perf_ctx
);
2426 gen_perf_close(perf_ctx
, query
->queryinfo
);
2432 #define GET_FIELD(word, field) (((word) & field ## _MASK) >> field ## _SHIFT)
2435 read_gt_frequency(struct gen_perf_context
*perf_ctx
,
2436 struct gen_perf_query_object
*obj
)
2438 const struct gen_device_info
*devinfo
= perf_ctx
->devinfo
;
2439 uint32_t start
= *((uint32_t *)(obj
->oa
.map
+ MI_FREQ_START_OFFSET_BYTES
)),
2440 end
= *((uint32_t *)(obj
->oa
.map
+ MI_FREQ_END_OFFSET_BYTES
));
2442 switch (devinfo
->gen
) {
2445 obj
->oa
.gt_frequency
[0] = GET_FIELD(start
, GEN7_RPSTAT1_CURR_GT_FREQ
) * 50ULL;
2446 obj
->oa
.gt_frequency
[1] = GET_FIELD(end
, GEN7_RPSTAT1_CURR_GT_FREQ
) * 50ULL;
2451 obj
->oa
.gt_frequency
[0] = GET_FIELD(start
, GEN9_RPSTAT0_CURR_GT_FREQ
) * 50ULL / 3ULL;
2452 obj
->oa
.gt_frequency
[1] = GET_FIELD(end
, GEN9_RPSTAT0_CURR_GT_FREQ
) * 50ULL / 3ULL;
2455 unreachable("unexpected gen");
2458 /* Put the numbers into Hz. */
2459 obj
->oa
.gt_frequency
[0] *= 1000000ULL;
2460 obj
->oa
.gt_frequency
[1] *= 1000000ULL;
2464 get_oa_counter_data(struct gen_perf_context
*perf_ctx
,
2465 struct gen_perf_query_object
*query
,
2469 struct gen_perf_config
*perf_cfg
= perf_ctx
->perf
;
2470 const struct gen_perf_query_info
*queryinfo
= query
->queryinfo
;
2471 int n_counters
= queryinfo
->n_counters
;
2474 for (int i
= 0; i
< n_counters
; i
++) {
2475 const struct gen_perf_query_counter
*counter
= &queryinfo
->counters
[i
];
2476 uint64_t *out_uint64
;
2478 size_t counter_size
= gen_perf_query_counter_get_size(counter
);
2481 switch (counter
->data_type
) {
2482 case GEN_PERF_COUNTER_DATA_TYPE_UINT64
:
2483 out_uint64
= (uint64_t *)(data
+ counter
->offset
);
2485 counter
->oa_counter_read_uint64(perf_cfg
, queryinfo
,
2486 query
->oa
.result
.accumulator
);
2488 case GEN_PERF_COUNTER_DATA_TYPE_FLOAT
:
2489 out_float
= (float *)(data
+ counter
->offset
);
2491 counter
->oa_counter_read_float(perf_cfg
, queryinfo
,
2492 query
->oa
.result
.accumulator
);
2495 /* So far we aren't using uint32, double or bool32... */
2496 unreachable("unexpected counter data type");
2498 written
= counter
->offset
+ counter_size
;
2506 get_pipeline_stats_data(struct gen_perf_context
*perf_ctx
,
2507 struct gen_perf_query_object
*query
,
2512 struct gen_perf_config
*perf_cfg
= perf_ctx
->perf
;
2513 const struct gen_perf_query_info
*queryinfo
= query
->queryinfo
;
2514 int n_counters
= queryinfo
->n_counters
;
2517 uint64_t *start
= perf_cfg
->vtbl
.bo_map(perf_ctx
->ctx
, query
->pipeline_stats
.bo
, MAP_READ
);
2518 uint64_t *end
= start
+ (STATS_BO_END_OFFSET_BYTES
/ sizeof(uint64_t));
2520 for (int i
= 0; i
< n_counters
; i
++) {
2521 const struct gen_perf_query_counter
*counter
= &queryinfo
->counters
[i
];
2522 uint64_t value
= end
[i
] - start
[i
];
2524 if (counter
->pipeline_stat
.numerator
!=
2525 counter
->pipeline_stat
.denominator
) {
2526 value
*= counter
->pipeline_stat
.numerator
;
2527 value
/= counter
->pipeline_stat
.denominator
;
2530 *((uint64_t *)p
) = value
;
2534 perf_cfg
->vtbl
.bo_unmap(query
->pipeline_stats
.bo
);
2540 gen_perf_get_query_data(struct gen_perf_context
*perf_ctx
,
2541 struct gen_perf_query_object
*query
,
2544 unsigned *bytes_written
)
2546 struct gen_perf_config
*perf_cfg
= perf_ctx
->perf
;
2549 switch (query
->queryinfo
->kind
) {
2550 case GEN_PERF_QUERY_TYPE_OA
:
2551 case GEN_PERF_QUERY_TYPE_RAW
:
2552 if (!query
->oa
.results_accumulated
) {
2553 read_gt_frequency(perf_ctx
, query
);
2554 uint32_t *begin_report
= query
->oa
.map
;
2555 uint32_t *end_report
= query
->oa
.map
+ MI_RPC_BO_END_OFFSET_BYTES
;
2556 gen_perf_query_result_read_frequencies(&query
->oa
.result
,
2560 accumulate_oa_reports(perf_ctx
, query
);
2561 assert(query
->oa
.results_accumulated
);
2563 perf_cfg
->vtbl
.bo_unmap(query
->oa
.bo
);
2564 query
->oa
.map
= NULL
;
2566 if (query
->queryinfo
->kind
== GEN_PERF_QUERY_TYPE_OA
) {
2567 written
= get_oa_counter_data(perf_ctx
, query
, data_size
, (uint8_t *)data
);
2569 const struct gen_device_info
*devinfo
= perf_ctx
->devinfo
;
2571 written
= gen_perf_query_result_write_mdapi((uint8_t *)data
, data_size
,
2572 devinfo
, &query
->oa
.result
,
2573 query
->oa
.gt_frequency
[0],
2574 query
->oa
.gt_frequency
[1]);
2578 case GEN_PERF_QUERY_TYPE_PIPELINE
:
2579 written
= get_pipeline_stats_data(perf_ctx
, query
, data_size
, (uint8_t *)data
);
2583 unreachable("Unknown query type");
2588 *bytes_written
= written
;
2592 gen_perf_dump_query_count(struct gen_perf_context
*perf_ctx
)
2594 DBG("Queries: (Open queries = %d, OA users = %d)\n",
2595 perf_ctx
->n_active_oa_queries
, perf_ctx
->n_oa_users
);
2599 gen_perf_dump_query(struct gen_perf_context
*ctx
,
2600 struct gen_perf_query_object
*obj
,
2601 void *current_batch
)
2603 switch (obj
->queryinfo
->kind
) {
2604 case GEN_PERF_QUERY_TYPE_OA
:
2605 case GEN_PERF_QUERY_TYPE_RAW
:
2606 DBG("BO: %-4s OA data: %-10s %-15s\n",
2607 obj
->oa
.bo
? "yes," : "no,",
2608 gen_perf_is_query_ready(ctx
, obj
, current_batch
) ? "ready," : "not ready,",
2609 obj
->oa
.results_accumulated
? "accumulated" : "not accumulated");
2611 case GEN_PERF_QUERY_TYPE_PIPELINE
:
2613 obj
->pipeline_stats
.bo
? "yes" : "no");
2616 unreachable("Unknown query type");