Skip to content

Commit b91a9ab

Browse files
captain5050namhyung
authored andcommitted
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 <[email protected]> Tested-by: Arnaldo Carvalho de Melo <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Namhyung Kim <[email protected]>
1 parent 55c0968 commit b91a9ab

File tree

5 files changed

+23
-5
lines changed

5 files changed

+23
-5
lines changed

tools/perf/builtin-list.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ struct print_state {
5858
bool metrics;
5959
/** @metricgroups: Controls printing of metric and metric groups. */
6060
bool metricgroups;
61+
/** @exclude_abi: Exclude PMUs with types less than PERF_TYPE_MAX except PERF_TYPE_RAW. */
62+
bool exclude_abi;
6163
/** @last_topic: The last printed event topic. */
6264
char *last_topic;
6365
/** @last_metricgroups: The last printed metric group. */
@@ -113,7 +115,8 @@ static void wordwrap(FILE *fp, const char *s, int start, int max, int corr)
113115
}
114116
}
115117

116-
static void default_print_event(void *ps, const char *topic, const char *pmu_name,
118+
static void default_print_event(void *ps, const char *topic,
119+
const char *pmu_name, u32 pmu_type,
117120
const char *event_name, const char *event_alias,
118121
const char *scale_unit __maybe_unused,
119122
bool deprecated, const char *event_type_desc,
@@ -130,6 +133,9 @@ static void default_print_event(void *ps, const char *topic, const char *pmu_nam
130133
if (print_state->pmu_glob && pmu_name && !strglobmatch(pmu_name, print_state->pmu_glob))
131134
return;
132135

136+
if (print_state->exclude_abi && pmu_type < PERF_TYPE_MAX && pmu_type != PERF_TYPE_RAW)
137+
return;
138+
133139
if (print_state->event_glob &&
134140
(!event_name || !strglobmatch(event_name, print_state->event_glob)) &&
135141
(!event_alias || !strglobmatch(event_alias, print_state->event_glob)) &&
@@ -354,7 +360,8 @@ static void fix_escape_fprintf(FILE *fp, struct strbuf *buf, const char *fmt, ..
354360
fputs(buf->buf, fp);
355361
}
356362

357-
static void json_print_event(void *ps, const char *topic, const char *pmu_name,
363+
static void json_print_event(void *ps, const char *topic,
364+
const char *pmu_name, u32 pmu_type __maybe_unused,
358365
const char *event_name, const char *event_alias,
359366
const char *scale_unit,
360367
bool deprecated, const char *event_type_desc,
@@ -647,9 +654,11 @@ int cmd_list(int argc, const char **argv)
647654
} else if (strcmp(argv[i], "cache") == 0 ||
648655
strcmp(argv[i], "hwcache") == 0)
649656
print_hwcache_events(&print_cb, ps);
650-
else if (strcmp(argv[i], "pmu") == 0)
657+
else if (strcmp(argv[i], "pmu") == 0) {
658+
default_ps.exclude_abi = true;
651659
perf_pmus__print_pmu_events(&print_cb, ps);
652-
else if (strcmp(argv[i], "sdt") == 0)
660+
default_ps.exclude_abi = false;
661+
} else if (strcmp(argv[i], "sdt") == 0)
653662
print_sdt_events(&print_cb, ps);
654663
else if (strcmp(argv[i], "metric") == 0 || strcmp(argv[i], "metrics") == 0) {
655664
default_ps.metricgroups = false;

tools/perf/util/pfm.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ print_libpfm_event(const struct print_callbacks *print_cb, void *print_state,
230230

231231
if (is_libpfm_event_supported(name, cpus, threads)) {
232232
print_cb->print_event(print_state, topic, pinfo->name,
233+
/*pmu_type=*/PERF_TYPE_RAW,
233234
name, info->equiv,
234235
/*scale_unit=*/NULL,
235236
/*deprecated=*/NULL, "PFM event",
@@ -265,6 +266,7 @@ print_libpfm_event(const struct print_callbacks *print_cb, void *print_state,
265266
print_cb->print_event(print_state,
266267
topic,
267268
pinfo->name,
269+
/*pmu_type=*/PERF_TYPE_RAW,
268270
name, /*alias=*/NULL,
269271
/*scale_unit=*/NULL,
270272
/*deprecated=*/NULL, "PFM event",

tools/perf/util/pmus.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,7 @@ void perf_pmus__print_pmu_events(const struct print_callbacks *print_cb, void *p
645645
print_cb->print_event(print_state,
646646
aliases[j].topic,
647647
aliases[j].pmu_name,
648+
aliases[j].pmu->type,
648649
aliases[j].name,
649650
aliases[j].alias,
650651
aliases[j].scale_unit,
@@ -749,6 +750,7 @@ void perf_pmus__print_raw_pmu_events(const struct print_callbacks *print_cb, voi
749750
print_cb->print_event(print_state,
750751
/*topic=*/NULL,
751752
/*pmu_name=*/NULL,
753+
pmu->type,
752754
format_args.short_string.buf,
753755
/*event_alias=*/NULL,
754756
/*scale_unit=*/NULL,

tools/perf/util/print-events.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ void print_sdt_events(const struct print_callbacks *print_cb, void *print_state)
121121
print_cb->print_event(print_state,
122122
/*topic=*/NULL,
123123
/*pmu_name=*/NULL,
124+
PERF_TYPE_TRACEPOINT,
124125
evt_name ?: sdt_name->s,
125126
/*event_alias=*/NULL,
126127
/*deprecated=*/false,
@@ -222,6 +223,7 @@ int print_hwcache_events(const struct print_callbacks *print_cb, void *print_sta
222223
print_cb->print_event(print_state,
223224
"cache",
224225
pmu->name,
226+
pmu->type,
225227
name,
226228
alias_name,
227229
/*scale_unit=*/NULL,
@@ -278,6 +280,7 @@ void print_symbol_events(const struct print_callbacks *print_cb, void *print_sta
278280
print_cb->print_event(print_state,
279281
/*topic=*/NULL,
280282
/*pmu_name=*/NULL,
283+
type,
281284
nd->s,
282285
alias,
283286
/*scale_unit=*/NULL,
@@ -438,6 +441,7 @@ void print_events(const struct print_callbacks *print_cb, void *print_state)
438441
print_cb->print_event(print_state,
439442
/*topic=*/NULL,
440443
/*pmu_name=*/NULL,
444+
PERF_TYPE_RAW,
441445
"rNNN",
442446
/*event_alias=*/NULL,
443447
/*scale_unit=*/NULL,
@@ -452,6 +456,7 @@ void print_events(const struct print_callbacks *print_cb, void *print_state)
452456
print_cb->print_event(print_state,
453457
/*topic=*/NULL,
454458
/*pmu_name=*/NULL,
459+
PERF_TYPE_BREAKPOINT,
455460
"mem:<addr>[/len][:access]",
456461
/*scale_unit=*/NULL,
457462
/*event_alias=*/NULL,

tools/perf/util/print-events.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ struct print_callbacks {
1212
void (*print_start)(void *print_state);
1313
void (*print_end)(void *print_state);
1414
void (*print_event)(void *print_state, const char *topic,
15-
const char *pmu_name,
15+
const char *pmu_name, u32 pmu_type,
1616
const char *event_name, const char *event_alias,
1717
const char *scale_unit,
1818
bool deprecated, const char *event_type_desc,

0 commit comments

Comments
 (0)