Skip to content

Commit 84d1b20

Browse files
namhyungacmel
authored andcommitted
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: 86895b4 ("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>
1 parent 59f2f4b commit 84d1b20

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

tools/perf/util/stat-display.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ static void printout(struct perf_stat_config *config, struct aggr_cpu_id id, int
559559
[AGGR_CORE] = 2,
560560
[AGGR_THREAD] = 1,
561561
[AGGR_UNSET] = 0,
562-
[AGGR_NODE] = 0,
562+
[AGGR_NODE] = 1,
563563
};
564564

565565
pm = config->metric_only ? print_metric_only_csv : print_metric_csv;
@@ -1124,6 +1124,7 @@ static int aggr_header_lens[] = {
11241124
[AGGR_SOCKET] = 12,
11251125
[AGGR_NONE] = 6,
11261126
[AGGR_THREAD] = 24,
1127+
[AGGR_NODE] = 6,
11271128
[AGGR_GLOBAL] = 0,
11281129
};
11291130

@@ -1133,6 +1134,7 @@ static const char *aggr_header_csv[] = {
11331134
[AGGR_SOCKET] = "socket,cpus",
11341135
[AGGR_NONE] = "cpu,",
11351136
[AGGR_THREAD] = "comm-pid,",
1137+
[AGGR_NODE] = "node,",
11361138
[AGGR_GLOBAL] = ""
11371139
};
11381140

0 commit comments

Comments
 (0)