]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
perf stat: Fix crash with --per-node --metric-only in CSV mode
authorNamhyung Kim <namhyung@kernel.org>
Mon, 7 Nov 2022 21:33:06 +0000 (13:33 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 16 Nov 2022 09:03:58 +0000 (10:03 +0100)
[ Upstream commit 84d1b2013272947ad9b13025df89226d8fa31cc5 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/perf/util/stat-display.c

index b82844cb0ce77845ec1480def525e841fa65acb6..aa9d9d2936e7726173ab835da75506b82c21b9bc 100644 (file)
@@ -556,7 +556,7 @@ static void printout(struct perf_stat_config *config, struct aggr_cpu_id id, int
                        [AGGR_CORE] = 2,
                        [AGGR_THREAD] = 1,
                        [AGGR_UNSET] = 0,
-                       [AGGR_NODE] = 0,
+                       [AGGR_NODE] = 1,
                };
 
                pm = config->metric_only ? print_metric_only_csv : print_metric_csv;
@@ -1126,6 +1126,7 @@ static int aggr_header_lens[] = {
        [AGGR_SOCKET] = 12,
        [AGGR_NONE] = 6,
        [AGGR_THREAD] = 24,
+       [AGGR_NODE] = 6,
        [AGGR_GLOBAL] = 0,
 };
 
@@ -1135,6 +1136,7 @@ static const char *aggr_header_csv[] = {
        [AGGR_SOCKET]   =       "socket,cpus",
        [AGGR_NONE]     =       "cpu,",
        [AGGR_THREAD]   =       "comm-pid,",
+       [AGGR_NODE]     =       "node,",
        [AGGR_GLOBAL]   =       ""
 };