Re: [PATCH v3 10/10] perf list: Add json output option
From: Namhyung Kim
Date: Wed Nov 16 2022 - 18:05:10 EST
Hi,
On Tue, Nov 15, 2022 at 5:44 AM Arnaldo Carvalho de Melo
<acme@xxxxxxxxxx> wrote:
>
> Em Mon, Nov 14, 2022 at 01:07:23PM -0800, Ian Rogers escreveu:
> > Output events and metrics in a json format by overriding the print
> > callbacks. Currently other command line options aren't supported and
> > metrics are repeated once per metric group.
>
> Applied the patch with a few fixes and added this to the last cset:
>
> commit c9367a0658ebcfe8ab0bc4af2648f144c64b53a4
> Author: Ian Rogers <irogers@xxxxxxxxxx>
> Date: Mon Nov 14 13:07:23 2022 -0800
>
> perf list: Add JSON output option
>
> Output events and metrics in a JSON format by overriding the print
> callbacks. Currently other command line options aren't supported and
> metrics are repeated once per metric group.
>
> Committer testing:
>
> $ perf list cache
>
> List of pre-defined events (to be used in -e or -M):
>
> L1-dcache-load-misses [Hardware cache event]
> L1-dcache-loads [Hardware cache event]
> L1-dcache-prefetches [Hardware cache event]
> L1-icache-load-misses [Hardware cache event]
> L1-icache-loads [Hardware cache event]
> branch-load-misses [Hardware cache event]
> branch-loads [Hardware cache event]
> dTLB-load-misses [Hardware cache event]
> dTLB-loads [Hardware cache event]
> iTLB-load-misses [Hardware cache event]
> iTLB-loads [Hardware cache event]
> $ perf list --json cache
> [
> {
> "Unit": "cache",
It's confusing to call it 'unit', but we have it in the JSON metrics, sigh..
Thanks,
Namhyung
> "EventName": "L1-dcache-load-misses",
> "EventType": "Hardware cache event"
> },
> {
> "Unit": "cache",
> "EventName": "L1-dcache-loads",
> "EventType": "Hardware cache event"
> },
> {
> "Unit": "cache",
> "EventName": "L1-dcache-prefetches",
> "EventType": "Hardware cache event"
> },
> {
> "Unit": "cache",
> "EventName": "L1-icache-load-misses",
> "EventType": "Hardware cache event"
> },
> {
> "Unit": "cache",
> "EventName": "L1-icache-loads",
> "EventType": "Hardware cache event"
> },
> {
> "Unit": "cache",
> "EventName": "branch-load-misses",
> "EventType": "Hardware cache event"
> },
> {
> "Unit": "cache",
> "EventName": "branch-loads",
> "EventType": "Hardware cache event"
> },
> {
> "Unit": "cache",
> "EventName": "dTLB-load-misses",
> "EventType": "Hardware cache event"
> },
> {
> "Unit": "cache",
> "EventName": "dTLB-loads",
> "EventType": "Hardware cache event"
> },
> {
> "Unit": "cache",
> "EventName": "iTLB-load-misses",
> "EventType": "Hardware cache event"
> },
> {
> "Unit": "cache",
> "EventName": "iTLB-loads",
> "EventType": "Hardware cache event"
> }
> ]
> $
>
> Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
> Tested-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
> Cc: Adrian Hunter <adrian.hunter@xxxxxxxxx>
> Cc: Alexander Shishkin <alexander.shishkin@xxxxxxxxxxxxxxx>
> Cc: Caleb Biggers <caleb.biggers@xxxxxxxxx>
> Cc: Jiri Olsa <jolsa@xxxxxxxxxx>
> Cc: Kajol Jain <kjain@xxxxxxxxxxxxx>
> Cc: Kan Liang <kan.liang@xxxxxxxxxxxxxxx>
> Cc: Leo Yan <leo.yan@xxxxxxxxxx>
> Cc: Mark Rutland <mark.rutland@xxxxxxx>
> Cc: Namhyung Kim <namhyung@xxxxxxxxxx>
> Cc: Perry Taylor <perry.taylor@xxxxxxxxx>
> Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> Cc: Ravi Bangoria <ravi.bangoria@xxxxxxx>
> Cc: Rob Herring <robh@xxxxxxxxxx>
> Cc: Sandipan Das <sandipan.das@xxxxxxx>
> Cc: Stephane Eranian <eranian@xxxxxxxxxx>
> Cc: Weilin Wang <weilin.wang@xxxxxxxxx>
> Cc: Xin Gao <gaoxin@xxxxxxxxxx>
> Cc: Xing Zhengjun <zhengjun.xing@xxxxxxxxxxxxxxx>
> Link: http://lore.kernel.org/lkml/20221114210723.2749751-11-irogers@xxxxxxxxxx
> Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>