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

perf stat: Fix crash with --per-node --metric-only in CSV mode

The following command will get segfault due to missing aggr_header_csv
for AGGR_NODE:

$ sudo perf stat -a --per-node -x, --metric-only true

Committer testing:

Before this patch:

# perf stat -a --per-node -x, --metric-only true
Segmentation fault (core dumped)
#

After:

# gdb perf
-bash: gdb: command not found
# perf stat -a --per-node -x, --metric-only true
node,Ghz,frontend cycles idle,backend cycles idle,insn per cycle,branch-misses of all branches,
N0,32,0.335,2.10,0.65,0.69,0.03,1.92,
#

Fixes: 86895b480a2f10c7 ("perf stat: Add --per-node agregation support")
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: James Clark <james.clark@arm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
Link: http://lore.kernel.org/lkml/20221107213314.3239159-2-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Namhyung Kim and committed by
Arnaldo Carvalho de Melo
84d1b201 59f2f4b8

+3 -1
+3 -1
tools/perf/util/stat-display.c
··· 559 559 [AGGR_CORE] = 2, 560 560 [AGGR_THREAD] = 1, 561 561 [AGGR_UNSET] = 0, 562 - [AGGR_NODE] = 0, 562 + [AGGR_NODE] = 1, 563 563 }; 564 564 565 565 pm = config->metric_only ? print_metric_only_csv : print_metric_csv; ··· 1124 1124 [AGGR_SOCKET] = 12, 1125 1125 [AGGR_NONE] = 6, 1126 1126 [AGGR_THREAD] = 24, 1127 + [AGGR_NODE] = 6, 1127 1128 [AGGR_GLOBAL] = 0, 1128 1129 }; 1129 1130 ··· 1134 1133 [AGGR_SOCKET] = "socket,cpus", 1135 1134 [AGGR_NONE] = "cpu,", 1136 1135 [AGGR_THREAD] = "comm-pid,", 1136 + [AGGR_NODE] = "node,", 1137 1137 [AGGR_GLOBAL] = "" 1138 1138 }; 1139 1139