Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / tools / perf / util / pmus.c
blobb493da0d22ef7bc4637cd21182199cf9aa3addae
1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/list.h>
3 #include <linux/list_sort.h>
4 #include <linux/string.h>
5 #include <linux/zalloc.h>
6 #include <subcmd/pager.h>
7 #include <sys/types.h>
8 #include <ctype.h>
9 #include <dirent.h>
10 #include <pthread.h>
11 #include <string.h>
12 #include <unistd.h>
13 #include "cpumap.h"
14 #include "debug.h"
15 #include "evsel.h"
16 #include "pmus.h"
17 #include "pmu.h"
18 #include "hwmon_pmu.h"
19 #include "tool_pmu.h"
20 #include "print-events.h"
21 #include "strbuf.h"
24 * core_pmus: A PMU belongs to core_pmus if it's name is "cpu" or it's sysfs
25 * directory contains "cpus" file. All PMUs belonging to core_pmus
26 * must have pmu->is_core=1. If there are more than one PMU in
27 * this list, perf interprets it as a heterogeneous platform.
28 * (FWIW, certain ARM platforms having heterogeneous cores uses
29 * homogeneous PMU, and thus they are treated as homogeneous
30 * platform by perf because core_pmus will have only one entry)
31 * other_pmus: All other PMUs which are not part of core_pmus list. It doesn't
32 * matter whether PMU is present per SMT-thread or outside of the
33 * core in the hw. For e.g., an instance of AMD ibs_fetch// and
34 * ibs_op// PMUs is present in each hw SMT thread, however they
35 * are captured under other_pmus. PMUs belonging to other_pmus
36 * must have pmu->is_core=0 but pmu->is_uncore could be 0 or 1.
38 static LIST_HEAD(core_pmus);
39 static LIST_HEAD(other_pmus);
40 static bool read_sysfs_core_pmus;
41 static bool read_sysfs_all_pmus;
43 static void pmu_read_sysfs(bool core_only);
45 size_t pmu_name_len_no_suffix(const char *str)
47 int orig_len, len;
48 bool has_hex_digits = false;
50 orig_len = len = strlen(str);
52 /* Count trailing digits. */
53 while (len > 0 && isxdigit(str[len - 1])) {
54 if (!isdigit(str[len - 1]))
55 has_hex_digits = true;
56 len--;
59 if (len > 0 && len != orig_len && str[len - 1] == '_') {
61 * There is a '_{num}' suffix. For decimal suffixes any length
62 * will do, for hexadecimal ensure more than 2 hex digits so
63 * that S390's cpum_cf PMU doesn't match.
65 if (!has_hex_digits || (orig_len - len) > 2)
66 return len - 1;
68 /* Use the full length. */
69 return orig_len;
72 int pmu_name_cmp(const char *lhs_pmu_name, const char *rhs_pmu_name)
74 unsigned long long lhs_num = 0, rhs_num = 0;
75 size_t lhs_pmu_name_len = pmu_name_len_no_suffix(lhs_pmu_name);
76 size_t rhs_pmu_name_len = pmu_name_len_no_suffix(rhs_pmu_name);
77 int ret = strncmp(lhs_pmu_name, rhs_pmu_name,
78 lhs_pmu_name_len < rhs_pmu_name_len ? lhs_pmu_name_len : rhs_pmu_name_len);
80 if (lhs_pmu_name_len != rhs_pmu_name_len || ret != 0 || lhs_pmu_name_len == 0)
81 return ret;
83 if (lhs_pmu_name_len + 1 < strlen(lhs_pmu_name))
84 lhs_num = strtoull(&lhs_pmu_name[lhs_pmu_name_len + 1], NULL, 16);
85 if (rhs_pmu_name_len + 1 < strlen(rhs_pmu_name))
86 rhs_num = strtoull(&rhs_pmu_name[rhs_pmu_name_len + 1], NULL, 16);
88 return lhs_num < rhs_num ? -1 : (lhs_num > rhs_num ? 1 : 0);
91 void perf_pmus__destroy(void)
93 struct perf_pmu *pmu, *tmp;
95 list_for_each_entry_safe(pmu, tmp, &core_pmus, list) {
96 list_del(&pmu->list);
98 perf_pmu__delete(pmu);
100 list_for_each_entry_safe(pmu, tmp, &other_pmus, list) {
101 list_del(&pmu->list);
103 perf_pmu__delete(pmu);
105 read_sysfs_core_pmus = false;
106 read_sysfs_all_pmus = false;
109 static struct perf_pmu *pmu_find(const char *name)
111 struct perf_pmu *pmu;
113 list_for_each_entry(pmu, &core_pmus, list) {
114 if (!strcmp(pmu->name, name) ||
115 (pmu->alias_name && !strcmp(pmu->alias_name, name)))
116 return pmu;
118 list_for_each_entry(pmu, &other_pmus, list) {
119 if (!strcmp(pmu->name, name) ||
120 (pmu->alias_name && !strcmp(pmu->alias_name, name)))
121 return pmu;
124 return NULL;
127 struct perf_pmu *perf_pmus__find(const char *name)
129 struct perf_pmu *pmu;
130 int dirfd;
131 bool core_pmu;
134 * Once PMU is loaded it stays in the list,
135 * so we keep us from multiple reading/parsing
136 * the pmu format definitions.
138 pmu = pmu_find(name);
139 if (pmu)
140 return pmu;
142 if (read_sysfs_all_pmus)
143 return NULL;
145 core_pmu = is_pmu_core(name);
146 if (core_pmu && read_sysfs_core_pmus)
147 return NULL;
149 dirfd = perf_pmu__event_source_devices_fd();
150 pmu = perf_pmu__lookup(core_pmu ? &core_pmus : &other_pmus, dirfd, name,
151 /*eager_load=*/false);
152 close(dirfd);
154 if (!pmu) {
156 * Looking up an inidividual PMU failed. This may mean name is
157 * an alias, so read the PMUs from sysfs and try to find again.
159 pmu_read_sysfs(core_pmu);
160 pmu = pmu_find(name);
162 return pmu;
165 static struct perf_pmu *perf_pmu__find2(int dirfd, const char *name)
167 struct perf_pmu *pmu;
168 bool core_pmu;
171 * Once PMU is loaded it stays in the list,
172 * so we keep us from multiple reading/parsing
173 * the pmu format definitions.
175 pmu = pmu_find(name);
176 if (pmu)
177 return pmu;
179 if (read_sysfs_all_pmus)
180 return NULL;
182 core_pmu = is_pmu_core(name);
183 if (core_pmu && read_sysfs_core_pmus)
184 return NULL;
186 return perf_pmu__lookup(core_pmu ? &core_pmus : &other_pmus, dirfd, name,
187 /*eager_load=*/false);
190 static int pmus_cmp(void *priv __maybe_unused,
191 const struct list_head *lhs, const struct list_head *rhs)
193 struct perf_pmu *lhs_pmu = container_of(lhs, struct perf_pmu, list);
194 struct perf_pmu *rhs_pmu = container_of(rhs, struct perf_pmu, list);
196 return pmu_name_cmp(lhs_pmu->name ?: "", rhs_pmu->name ?: "");
199 /* Add all pmus in sysfs to pmu list: */
200 static void pmu_read_sysfs(bool core_only)
202 int fd;
203 DIR *dir;
204 struct dirent *dent;
205 struct perf_pmu *tool_pmu;
207 if (read_sysfs_all_pmus || (core_only && read_sysfs_core_pmus))
208 return;
210 fd = perf_pmu__event_source_devices_fd();
211 if (fd < 0)
212 return;
214 dir = fdopendir(fd);
215 if (!dir) {
216 close(fd);
217 return;
220 while ((dent = readdir(dir))) {
221 if (!strcmp(dent->d_name, ".") || !strcmp(dent->d_name, ".."))
222 continue;
223 if (core_only && !is_pmu_core(dent->d_name))
224 continue;
225 /* add to static LIST_HEAD(core_pmus) or LIST_HEAD(other_pmus): */
226 perf_pmu__find2(fd, dent->d_name);
229 closedir(dir);
230 if (list_empty(&core_pmus)) {
231 if (!perf_pmu__create_placeholder_core_pmu(&core_pmus))
232 pr_err("Failure to set up any core PMUs\n");
234 list_sort(NULL, &core_pmus, pmus_cmp);
235 if (!core_only) {
236 tool_pmu = perf_pmus__tool_pmu();
237 list_add_tail(&tool_pmu->list, &other_pmus);
238 perf_pmus__read_hwmon_pmus(&other_pmus);
240 list_sort(NULL, &other_pmus, pmus_cmp);
241 if (!list_empty(&core_pmus)) {
242 read_sysfs_core_pmus = true;
243 if (!core_only)
244 read_sysfs_all_pmus = true;
248 static struct perf_pmu *__perf_pmus__find_by_type(unsigned int type)
250 struct perf_pmu *pmu;
252 list_for_each_entry(pmu, &core_pmus, list) {
253 if (pmu->type == type)
254 return pmu;
257 list_for_each_entry(pmu, &other_pmus, list) {
258 if (pmu->type == type)
259 return pmu;
261 return NULL;
264 struct perf_pmu *perf_pmus__find_by_type(unsigned int type)
266 struct perf_pmu *pmu = __perf_pmus__find_by_type(type);
268 if (pmu || read_sysfs_all_pmus)
269 return pmu;
271 pmu_read_sysfs(/*core_only=*/false);
272 pmu = __perf_pmus__find_by_type(type);
273 return pmu;
277 * pmu iterator: If pmu is NULL, we start at the begin, otherwise return the
278 * next pmu. Returns NULL on end.
280 struct perf_pmu *perf_pmus__scan(struct perf_pmu *pmu)
282 bool use_core_pmus = !pmu || pmu->is_core;
284 if (!pmu) {
285 pmu_read_sysfs(/*core_only=*/false);
286 pmu = list_prepare_entry(pmu, &core_pmus, list);
288 if (use_core_pmus) {
289 list_for_each_entry_continue(pmu, &core_pmus, list)
290 return pmu;
292 pmu = NULL;
293 pmu = list_prepare_entry(pmu, &other_pmus, list);
295 list_for_each_entry_continue(pmu, &other_pmus, list)
296 return pmu;
297 return NULL;
300 struct perf_pmu *perf_pmus__scan_core(struct perf_pmu *pmu)
302 if (!pmu) {
303 pmu_read_sysfs(/*core_only=*/true);
304 return list_first_entry_or_null(&core_pmus, typeof(*pmu), list);
306 list_for_each_entry_continue(pmu, &core_pmus, list)
307 return pmu;
309 return NULL;
312 static struct perf_pmu *perf_pmus__scan_skip_duplicates(struct perf_pmu *pmu)
314 bool use_core_pmus = !pmu || pmu->is_core;
315 int last_pmu_name_len = 0;
316 const char *last_pmu_name = (pmu && pmu->name) ? pmu->name : "";
318 if (!pmu) {
319 pmu_read_sysfs(/*core_only=*/false);
320 pmu = list_prepare_entry(pmu, &core_pmus, list);
321 } else
322 last_pmu_name_len = pmu_name_len_no_suffix(pmu->name ?: "");
324 if (use_core_pmus) {
325 list_for_each_entry_continue(pmu, &core_pmus, list) {
326 int pmu_name_len = pmu_name_len_no_suffix(pmu->name ?: "");
328 if (last_pmu_name_len == pmu_name_len &&
329 !strncmp(last_pmu_name, pmu->name ?: "", pmu_name_len))
330 continue;
332 return pmu;
334 pmu = NULL;
335 pmu = list_prepare_entry(pmu, &other_pmus, list);
337 list_for_each_entry_continue(pmu, &other_pmus, list) {
338 int pmu_name_len = pmu_name_len_no_suffix(pmu->name ?: "");
340 if (last_pmu_name_len == pmu_name_len &&
341 !strncmp(last_pmu_name, pmu->name ?: "", pmu_name_len))
342 continue;
344 return pmu;
346 return NULL;
349 const struct perf_pmu *perf_pmus__pmu_for_pmu_filter(const char *str)
351 struct perf_pmu *pmu = NULL;
353 while ((pmu = perf_pmus__scan(pmu)) != NULL) {
354 if (!strcmp(pmu->name, str))
355 return pmu;
356 /* Ignore "uncore_" prefix. */
357 if (!strncmp(pmu->name, "uncore_", 7)) {
358 if (!strcmp(pmu->name + 7, str))
359 return pmu;
361 /* Ignore "cpu_" prefix on Intel hybrid PMUs. */
362 if (!strncmp(pmu->name, "cpu_", 4)) {
363 if (!strcmp(pmu->name + 4, str))
364 return pmu;
367 return NULL;
370 /** Struct for ordering events as output in perf list. */
371 struct sevent {
372 /** PMU for event. */
373 const struct perf_pmu *pmu;
374 const char *name;
375 const char* alias;
376 const char *scale_unit;
377 const char *desc;
378 const char *long_desc;
379 const char *encoding_desc;
380 const char *topic;
381 const char *pmu_name;
382 const char *event_type_desc;
383 bool deprecated;
386 static int cmp_sevent(const void *a, const void *b)
388 const struct sevent *as = a;
389 const struct sevent *bs = b;
390 bool a_iscpu, b_iscpu;
391 int ret;
393 /* Put extra events last. */
394 if (!!as->desc != !!bs->desc)
395 return !!as->desc - !!bs->desc;
397 /* Order by topics. */
398 ret = strcmp(as->topic ?: "", bs->topic ?: "");
399 if (ret)
400 return ret;
402 /* Order CPU core events to be first */
403 a_iscpu = as->pmu ? as->pmu->is_core : true;
404 b_iscpu = bs->pmu ? bs->pmu->is_core : true;
405 if (a_iscpu != b_iscpu)
406 return a_iscpu ? -1 : 1;
408 /* Order by PMU name. */
409 if (as->pmu != bs->pmu) {
410 ret = strcmp(as->pmu_name ?: "", bs->pmu_name ?: "");
411 if (ret)
412 return ret;
415 /* Order by event name. */
416 return strcmp(as->name, bs->name);
419 static bool pmu_alias_is_duplicate(struct sevent *a, struct sevent *b)
421 /* Different names -> never duplicates */
422 if (strcmp(a->name ?: "//", b->name ?: "//"))
423 return false;
425 /* Don't remove duplicates for different PMUs */
426 return strcmp(a->pmu_name, b->pmu_name) == 0;
429 struct events_callback_state {
430 struct sevent *aliases;
431 size_t aliases_len;
432 size_t index;
435 static int perf_pmus__print_pmu_events__callback(void *vstate,
436 struct pmu_event_info *info)
438 struct events_callback_state *state = vstate;
439 struct sevent *s;
441 if (state->index >= state->aliases_len) {
442 pr_err("Unexpected event %s/%s/\n", info->pmu->name, info->name);
443 return 1;
445 assert(info->pmu != NULL || info->name != NULL);
446 s = &state->aliases[state->index];
447 s->pmu = info->pmu;
448 #define COPY_STR(str) s->str = info->str ? strdup(info->str) : NULL
449 COPY_STR(name);
450 COPY_STR(alias);
451 COPY_STR(scale_unit);
452 COPY_STR(desc);
453 COPY_STR(long_desc);
454 COPY_STR(encoding_desc);
455 COPY_STR(topic);
456 COPY_STR(pmu_name);
457 COPY_STR(event_type_desc);
458 #undef COPY_STR
459 s->deprecated = info->deprecated;
460 state->index++;
461 return 0;
464 void perf_pmus__print_pmu_events(const struct print_callbacks *print_cb, void *print_state)
466 struct perf_pmu *pmu;
467 int printed = 0;
468 int len;
469 struct sevent *aliases;
470 struct events_callback_state state;
471 bool skip_duplicate_pmus = print_cb->skip_duplicate_pmus(print_state);
472 struct perf_pmu *(*scan_fn)(struct perf_pmu *);
474 if (skip_duplicate_pmus)
475 scan_fn = perf_pmus__scan_skip_duplicates;
476 else
477 scan_fn = perf_pmus__scan;
479 pmu = NULL;
480 len = 0;
481 while ((pmu = scan_fn(pmu)) != NULL)
482 len += perf_pmu__num_events(pmu);
484 aliases = zalloc(sizeof(struct sevent) * len);
485 if (!aliases) {
486 pr_err("FATAL: not enough memory to print PMU events\n");
487 return;
489 pmu = NULL;
490 state = (struct events_callback_state) {
491 .aliases = aliases,
492 .aliases_len = len,
493 .index = 0,
495 while ((pmu = scan_fn(pmu)) != NULL) {
496 perf_pmu__for_each_event(pmu, skip_duplicate_pmus, &state,
497 perf_pmus__print_pmu_events__callback);
499 qsort(aliases, len, sizeof(struct sevent), cmp_sevent);
500 for (int j = 0; j < len; j++) {
501 /* Skip duplicates */
502 if (j < len - 1 && pmu_alias_is_duplicate(&aliases[j], &aliases[j + 1]))
503 goto free;
505 print_cb->print_event(print_state,
506 aliases[j].topic,
507 aliases[j].pmu_name,
508 aliases[j].name,
509 aliases[j].alias,
510 aliases[j].scale_unit,
511 aliases[j].deprecated,
512 aliases[j].event_type_desc,
513 aliases[j].desc,
514 aliases[j].long_desc,
515 aliases[j].encoding_desc);
516 free:
517 zfree(&aliases[j].name);
518 zfree(&aliases[j].alias);
519 zfree(&aliases[j].scale_unit);
520 zfree(&aliases[j].desc);
521 zfree(&aliases[j].long_desc);
522 zfree(&aliases[j].encoding_desc);
523 zfree(&aliases[j].topic);
524 zfree(&aliases[j].pmu_name);
525 zfree(&aliases[j].event_type_desc);
527 if (printed && pager_in_use())
528 printf("\n");
530 zfree(&aliases);
533 struct build_format_string_args {
534 struct strbuf short_string;
535 struct strbuf long_string;
536 int num_formats;
539 static int build_format_string(void *state, const char *name, int config,
540 const unsigned long *bits)
542 struct build_format_string_args *args = state;
543 unsigned int num_bits;
544 int ret1, ret2 = 0;
546 (void)config;
547 args->num_formats++;
548 if (args->num_formats > 1) {
549 strbuf_addch(&args->long_string, ',');
550 if (args->num_formats < 4)
551 strbuf_addch(&args->short_string, ',');
553 num_bits = bits ? bitmap_weight(bits, PERF_PMU_FORMAT_BITS) : 0;
554 if (num_bits <= 1) {
555 ret1 = strbuf_addf(&args->long_string, "%s", name);
556 if (args->num_formats < 4)
557 ret2 = strbuf_addf(&args->short_string, "%s", name);
558 } else if (num_bits > 8) {
559 ret1 = strbuf_addf(&args->long_string, "%s=0..0x%llx", name,
560 ULLONG_MAX >> (64 - num_bits));
561 if (args->num_formats < 4) {
562 ret2 = strbuf_addf(&args->short_string, "%s=0..0x%llx", name,
563 ULLONG_MAX >> (64 - num_bits));
565 } else {
566 ret1 = strbuf_addf(&args->long_string, "%s=0..%llu", name,
567 ULLONG_MAX >> (64 - num_bits));
568 if (args->num_formats < 4) {
569 ret2 = strbuf_addf(&args->short_string, "%s=0..%llu", name,
570 ULLONG_MAX >> (64 - num_bits));
573 return ret1 < 0 ? ret1 : (ret2 < 0 ? ret2 : 0);
576 void perf_pmus__print_raw_pmu_events(const struct print_callbacks *print_cb, void *print_state)
578 bool skip_duplicate_pmus = print_cb->skip_duplicate_pmus(print_state);
579 struct perf_pmu *(*scan_fn)(struct perf_pmu *);
580 struct perf_pmu *pmu = NULL;
582 if (skip_duplicate_pmus)
583 scan_fn = perf_pmus__scan_skip_duplicates;
584 else
585 scan_fn = perf_pmus__scan;
587 while ((pmu = scan_fn(pmu)) != NULL) {
588 struct build_format_string_args format_args = {
589 .short_string = STRBUF_INIT,
590 .long_string = STRBUF_INIT,
591 .num_formats = 0,
593 int len = pmu_name_len_no_suffix(pmu->name);
594 const char *desc = "(see 'man perf-list' or 'man perf-record' on how to encode it)";
596 if (!pmu->is_core)
597 desc = NULL;
599 strbuf_addf(&format_args.short_string, "%.*s/", len, pmu->name);
600 strbuf_addf(&format_args.long_string, "%.*s/", len, pmu->name);
601 perf_pmu__for_each_format(pmu, &format_args, build_format_string);
603 if (format_args.num_formats > 3)
604 strbuf_addf(&format_args.short_string, ",.../modifier");
605 else
606 strbuf_addf(&format_args.short_string, "/modifier");
608 strbuf_addf(&format_args.long_string, "/modifier");
609 print_cb->print_event(print_state,
610 /*topic=*/NULL,
611 /*pmu_name=*/NULL,
612 format_args.short_string.buf,
613 /*event_alias=*/NULL,
614 /*scale_unit=*/NULL,
615 /*deprecated=*/false,
616 "Raw event descriptor",
617 desc,
618 /*long_desc=*/NULL,
619 format_args.long_string.buf);
621 strbuf_release(&format_args.short_string);
622 strbuf_release(&format_args.long_string);
626 bool perf_pmus__have_event(const char *pname, const char *name)
628 struct perf_pmu *pmu = perf_pmus__find(pname);
630 return pmu && perf_pmu__have_event(pmu, name);
633 int perf_pmus__num_core_pmus(void)
635 static int count;
637 if (!count) {
638 struct perf_pmu *pmu = NULL;
640 while ((pmu = perf_pmus__scan_core(pmu)) != NULL)
641 count++;
643 return count;
646 static bool __perf_pmus__supports_extended_type(void)
648 struct perf_pmu *pmu = NULL;
650 if (perf_pmus__num_core_pmus() <= 1)
651 return false;
653 while ((pmu = perf_pmus__scan_core(pmu)) != NULL) {
654 if (!is_event_supported(PERF_TYPE_HARDWARE, PERF_COUNT_HW_CPU_CYCLES | ((__u64)pmu->type << PERF_PMU_TYPE_SHIFT)))
655 return false;
658 return true;
661 static bool perf_pmus__do_support_extended_type;
663 static void perf_pmus__init_supports_extended_type(void)
665 perf_pmus__do_support_extended_type = __perf_pmus__supports_extended_type();
668 bool perf_pmus__supports_extended_type(void)
670 static pthread_once_t extended_type_once = PTHREAD_ONCE_INIT;
672 pthread_once(&extended_type_once, perf_pmus__init_supports_extended_type);
674 return perf_pmus__do_support_extended_type;
677 char *perf_pmus__default_pmu_name(void)
679 int fd;
680 DIR *dir;
681 struct dirent *dent;
682 char *result = NULL;
684 if (!list_empty(&core_pmus))
685 return strdup(list_first_entry(&core_pmus, struct perf_pmu, list)->name);
687 fd = perf_pmu__event_source_devices_fd();
688 if (fd < 0)
689 return strdup("cpu");
691 dir = fdopendir(fd);
692 if (!dir) {
693 close(fd);
694 return strdup("cpu");
697 while ((dent = readdir(dir))) {
698 if (!strcmp(dent->d_name, ".") || !strcmp(dent->d_name, ".."))
699 continue;
700 if (is_pmu_core(dent->d_name)) {
701 result = strdup(dent->d_name);
702 break;
706 closedir(dir);
707 return result ?: strdup("cpu");
710 struct perf_pmu *evsel__find_pmu(const struct evsel *evsel)
712 struct perf_pmu *pmu = evsel->pmu;
714 if (!pmu) {
715 pmu = perf_pmus__find_by_type(evsel->core.attr.type);
716 ((struct evsel *)evsel)->pmu = pmu;
718 return pmu;
721 struct perf_pmu *perf_pmus__find_core_pmu(void)
723 return perf_pmus__scan_core(NULL);
726 struct perf_pmu *perf_pmus__add_test_pmu(int test_sysfs_dirfd, const char *name)
729 * Some PMU functions read from the sysfs mount point, so care is
730 * needed, hence passing the eager_load flag to load things like the
731 * format files.
733 return perf_pmu__lookup(&other_pmus, test_sysfs_dirfd, name, /*eager_load=*/true);
736 struct perf_pmu *perf_pmus__add_test_hwmon_pmu(int hwmon_dir,
737 const char *sysfs_name,
738 const char *name)
740 return hwmon_pmu__new(&other_pmus, hwmon_dir, sysfs_name, name);
743 struct perf_pmu *perf_pmus__fake_pmu(void)
745 static struct perf_pmu fake = {
746 .name = "fake",
747 .type = PERF_PMU_TYPE_FAKE,
748 .format = LIST_HEAD_INIT(fake.format),
751 return &fake;