Re: [PATCH v3 07/18] perf stat: Remove hard coded shadow metrics

From: Namhyung Kim

Date: Tue Nov 11 2025 - 02:14:45 EST


On Mon, Nov 10, 2025 at 08:04:06PM -0800, Ian Rogers wrote:
> Now that the metrics are encoded in common json the hard coded
> printing means the metrics are shown twice. Remove the hard coded
> version.
>
> This means that when specifying events, and those events correspond to
> a hard coded metric, the metric will no longer be displayed. The
> metric will be displayed if the metric is requested. Due to the adhoc
> printing in the previous approach it was often found frustrating, the
> new approach avoids this.
>
> The default perf stat output on an alderlake now looks like:
> ```
> $ perf stat -a -- sleep 1
>
> Performance counter stats for 'system wide':
>
> 7,932 context-switches # 281.7 cs/sec cs_per_second
> TopdownL1 (cpu_core) # 10.3 % tma_bad_speculation
> # 17.3 % tma_frontend_bound
> TopdownL1 (cpu_core) # 37.3 % tma_backend_bound
> # 35.2 % tma_retiring
> 5,901 page-faults # 209.5 faults/sec page_faults_per_second
> 418,955,116 cpu_atom/cpu-cycles/ # 0.0 GHz cycles_frequency (49.77%)
> 1,113,933,476 cpu_core/cpu-cycles/ # 0.0 GHz cycles_frequency
> # 14.6 % tma_bad_speculation
> # 8.5 % tma_retiring (50.17%)
> # 41.8 % tma_backend_bound
> # 35.1 % tma_frontend_bound (50.31%)

I'd like to merge the alignment fix for this.

https://lore.kernel.org/r/20251106072834.1750880-1-namhyung@xxxxxxxxxx


> 32,196,918 cpu_atom/branches/ # 1.1 K/sec branch_frequency (60.24%)
> 445,404,717 cpu_core/branches/ # 15.8 K/sec branch_frequency
> 235 cpu-migrations # 8.3 migrations/sec migrations_per_second
> 28,160,951,165 cpu-clock # 28.0 CPUs CPUs_utilized
> 382,285,763 cpu_atom/cpu-cycles/ # 0.4 instructions insn_per_cycle (60.18%)
> 1,114,029,255 cpu_core/cpu-cycles/ # 2.3 instructions insn_per_cycle
> 1,768,727 cpu_atom/branches-misses/ # 6.5 % branch_miss_rate (49.68%)
> 4,505,904 cpu_core/branches-misses/ # 1.0 % branch_miss_rate
>
> 1.007137632 seconds time elapsed
> ```
>
> Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
> ---
> tools/perf/builtin-script.c | 1 -
> tools/perf/util/stat-display.c | 4 +-
> tools/perf/util/stat-shadow.c | 392 +--------------------------------
> tools/perf/util/stat.h | 2 +-
> 4 files changed, 6 insertions(+), 393 deletions(-)

Nice work!

Thanks,
Namhyung