Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf list: Skip ABI PMUs when printing pmu values

Avoid printing tracepoint, legacy and software events when listing for
the pmu option. Add the PMU type to the print_event callbacks to ease
detection.

Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Link: https://lore.kernel.org/r/20250725185202.68671-8-irogers@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>

authored by

Ian Rogers and committed by
Namhyung Kim
b91a9abb 55c09681

+23 -5
+13 -4
tools/perf/builtin-list.c
··· 58 58 bool metrics; 59 59 /** @metricgroups: Controls printing of metric and metric groups. */ 60 60 bool metricgroups; 61 + /** @exclude_abi: Exclude PMUs with types less than PERF_TYPE_MAX except PERF_TYPE_RAW. */ 62 + bool exclude_abi; 61 63 /** @last_topic: The last printed event topic. */ 62 64 char *last_topic; 63 65 /** @last_metricgroups: The last printed metric group. */ ··· 115 113 } 116 114 } 117 115 118 - static void default_print_event(void *ps, const char *topic, const char *pmu_name, 116 + static void default_print_event(void *ps, const char *topic, 117 + const char *pmu_name, u32 pmu_type, 119 118 const char *event_name, const char *event_alias, 120 119 const char *scale_unit __maybe_unused, 121 120 bool deprecated, const char *event_type_desc, ··· 131 128 return; 132 129 133 130 if (print_state->pmu_glob && pmu_name && !strglobmatch(pmu_name, print_state->pmu_glob)) 131 + return; 132 + 133 + if (print_state->exclude_abi && pmu_type < PERF_TYPE_MAX && pmu_type != PERF_TYPE_RAW) 134 134 return; 135 135 136 136 if (print_state->event_glob && ··· 360 354 fputs(buf->buf, fp); 361 355 } 362 356 363 - static void json_print_event(void *ps, const char *topic, const char *pmu_name, 357 + static void json_print_event(void *ps, const char *topic, 358 + const char *pmu_name, u32 pmu_type __maybe_unused, 364 359 const char *event_name, const char *event_alias, 365 360 const char *scale_unit, 366 361 bool deprecated, const char *event_type_desc, ··· 654 647 } else if (strcmp(argv[i], "cache") == 0 || 655 648 strcmp(argv[i], "hwcache") == 0) 656 649 print_hwcache_events(&print_cb, ps); 657 - else if (strcmp(argv[i], "pmu") == 0) 650 + else if (strcmp(argv[i], "pmu") == 0) { 651 + default_ps.exclude_abi = true; 658 652 perf_pmus__print_pmu_events(&print_cb, ps); 659 - else if (strcmp(argv[i], "sdt") == 0) 653 + default_ps.exclude_abi = false; 654 + } else if (strcmp(argv[i], "sdt") == 0) 660 655 print_sdt_events(&print_cb, ps); 661 656 else if (strcmp(argv[i], "metric") == 0 || strcmp(argv[i], "metrics") == 0) { 662 657 default_ps.metricgroups = false;
+2
tools/perf/util/pfm.c
··· 230 230 231 231 if (is_libpfm_event_supported(name, cpus, threads)) { 232 232 print_cb->print_event(print_state, topic, pinfo->name, 233 + /*pmu_type=*/PERF_TYPE_RAW, 233 234 name, info->equiv, 234 235 /*scale_unit=*/NULL, 235 236 /*deprecated=*/NULL, "PFM event", ··· 266 265 print_cb->print_event(print_state, 267 266 topic, 268 267 pinfo->name, 268 + /*pmu_type=*/PERF_TYPE_RAW, 269 269 name, /*alias=*/NULL, 270 270 /*scale_unit=*/NULL, 271 271 /*deprecated=*/NULL, "PFM event",
+2
tools/perf/util/pmus.c
··· 645 645 print_cb->print_event(print_state, 646 646 aliases[j].topic, 647 647 aliases[j].pmu_name, 648 + aliases[j].pmu->type, 648 649 aliases[j].name, 649 650 aliases[j].alias, 650 651 aliases[j].scale_unit, ··· 750 749 print_cb->print_event(print_state, 751 750 /*topic=*/NULL, 752 751 /*pmu_name=*/NULL, 752 + pmu->type, 753 753 format_args.short_string.buf, 754 754 /*event_alias=*/NULL, 755 755 /*scale_unit=*/NULL,
+5
tools/perf/util/print-events.c
··· 121 121 print_cb->print_event(print_state, 122 122 /*topic=*/NULL, 123 123 /*pmu_name=*/NULL, 124 + PERF_TYPE_TRACEPOINT, 124 125 evt_name ?: sdt_name->s, 125 126 /*event_alias=*/NULL, 126 127 /*deprecated=*/false, ··· 223 222 print_cb->print_event(print_state, 224 223 "cache", 225 224 pmu->name, 225 + pmu->type, 226 226 name, 227 227 alias_name, 228 228 /*scale_unit=*/NULL, ··· 280 278 print_cb->print_event(print_state, 281 279 /*topic=*/NULL, 282 280 /*pmu_name=*/NULL, 281 + type, 283 282 nd->s, 284 283 alias, 285 284 /*scale_unit=*/NULL, ··· 441 438 print_cb->print_event(print_state, 442 439 /*topic=*/NULL, 443 440 /*pmu_name=*/NULL, 441 + PERF_TYPE_RAW, 444 442 "rNNN", 445 443 /*event_alias=*/NULL, 446 444 /*scale_unit=*/NULL, ··· 456 452 print_cb->print_event(print_state, 457 453 /*topic=*/NULL, 458 454 /*pmu_name=*/NULL, 455 + PERF_TYPE_BREAKPOINT, 459 456 "mem:<addr>[/len][:access]", 460 457 /*scale_unit=*/NULL, 461 458 /*event_alias=*/NULL,
+1 -1
tools/perf/util/print-events.h
··· 12 12 void (*print_start)(void *print_state); 13 13 void (*print_end)(void *print_state); 14 14 void (*print_event)(void *print_state, const char *topic, 15 - const char *pmu_name, 15 + const char *pmu_name, u32 pmu_type, 16 16 const char *event_name, const char *event_alias, 17 17 const char *scale_unit, 18 18 bool deprecated, const char *event_type_desc,