Re: [PATCH v7] perf stat: Include PMU name and split uncore events per PMU in metric-only JSON output

From: Chun-Tse Shao

Date: Wed Nov 11 2026 - 13:51:34 EST


On Tue, Nov 10, 2026 at 10:29 PM Namhyung Kim <namhyung@xxxxxxxxxx> wrote:
>
> On Tue, Nov 10, 2026 at 11:22:38AM +0800, Hang Zhengyang wrote:
> > On Fri, 30 Oct 2026 12:25:37 -0700, Chun-Tse Shao wrote:
> > > When running `perf stat` with `-A` (--no-aggr) and `--metric-only` in
> > > JSON output mode (`-j`), [...]
> >
> > Tested on AMD Zen 3 on top of perf-tools-next 13a8d580433a. With
> > '-M l3_cache,data_fabric,iotlb -a -A --metric-only -j' the metrics are
> > now on separate lines labeled amd_l3, amd_df and amd_iommu_0. STD, CSV
> > and aggregated JSON output are unchanged, and the stat linters pass.
> >
> > Tested-by: Hang Zhengyang <hang.zhengyang1010@xxxxxxxxx>
> >
> > Two changes the changelog doesn't mention:
> >
> > - Without -M, 'perf stat -a -A --metric-only -j' now prints two lines
> > per CPU; the first is labeled "pmu" : "software".
> >
> > - Plain 'perf stat -a -A -j' gets the "pmu" key too.

Thank you for the testing. Yes it needs to be fixed:

```
$perf stat -a -A -M branch_miss_rate,cs_per_second --metric-only -j -- sleep 1
{"cpu" : "0", "pmu" : "software", "cs/sec cs_per_second" : "1211.5"}
{"cpu" : "0", "% branch_miss_rate" : "1.3"}
...
```

The fix should skip printing `software` pmu like `tool` and `cpu`.
Also, PMU printing should be skipped in non-metric-only mode.

v8: lore.kernel.org/20261111183209.1892421-1-ctshao@xxxxxxxxxx

-CT

> >
> > Are those intended?
>
> I believe it's intended and looks fine.
>
> Ian, are you ok with this?
>
> Thanks,
> Na