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

Configure Feed

Select the types of activity you want to include in your feed.

perf list: Support filtering in JSON output

Like regular output mode, it should honor command line arguments to
limit to a certain type of PMUs or events.

$ perf list -j hw
[
{
"Unit": "cpu",
"Topic": "legacy hardware",
"EventName": "branch-instructions",
"EventType": "Kernel PMU event",
"BriefDescription": "Retired branch instructions [This event is an alias of branches]",
"Encoding": "cpu/event=0xc4\n/"
},
{
"Unit": "cpu",
"Topic": "legacy hardware",
"EventName": "branch-misses",
"EventType": "Kernel PMU event",
"BriefDescription": "Mispredicted branch instructions",
"Encoding": "cpu/event=0xc5\n/"
},
...

Reviewed-by: Ian Rogers <irogers@google.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>

+24
+24
tools/perf/builtin-list.c
··· 373 373 FILE *fp = print_state->common.fp; 374 374 struct strbuf buf; 375 375 376 + if (deprecated && !print_state->common.deprecated) 377 + return; 378 + 379 + if (print_state->common.pmu_glob && 380 + (!pmu_name || !strglobmatch(pmu_name, print_state->common.pmu_glob))) 381 + return; 382 + 383 + if (print_state->common.exclude_abi && pmu_type < PERF_TYPE_MAX && 384 + pmu_type != PERF_TYPE_RAW) 385 + return; 386 + 387 + if (print_state->common.event_glob && 388 + (!event_name || !strglobmatch(event_name, print_state->common.event_glob)) && 389 + (!event_alias || !strglobmatch(event_alias, print_state->common.event_glob)) && 390 + (!topic || !strglobmatch_nocase(topic, print_state->common.event_glob))) 391 + return; 392 + 376 393 strbuf_init(&buf, 0); 377 394 fprintf(fp, "%s{\n", print_state->need_sep ? ",\n" : ""); 378 395 print_state->need_sep = true; ··· 465 448 bool need_sep = false; 466 449 FILE *fp = print_state->common.fp; 467 450 struct strbuf buf; 451 + 452 + if (print_state->common.event_glob && 453 + (!print_state->common.metrics || !name || 454 + !strglobmatch(name, print_state->common.event_glob)) && 455 + (!print_state->common.metricgroups || !group || 456 + !strglobmatch(group, print_state->common.event_glob))) 457 + return; 468 458 469 459 strbuf_init(&buf, 0); 470 460 fprintf(fp, "%s{\n", print_state->need_sep ? ",\n" : "");