Skip to content

Commit ce37ab3

Browse files
captain5050acmel
authored andcommitted
perf stat: Correct first_shadow_cpu to return index
perf_stat__update_shadow_stats() and perf_stat__print_shadow_stats() use a cpu map index rather than a CPU, but first_shadow_cpu is returning the wrong value for this. Change first_shadow_cpu to first_shadow_cpu_map_idx to make things agree. Signed-off-by: Ian Rogers <irogers@google.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: James Clark <james.clark@arm.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: John Garry <john.garry@huawei.com> Cc: Kajol Jain <kjain@linux.ibm.com> Cc: Kan Liang <kan.liang@linux.intel.com> Cc: Leo Yan <leo.yan@linaro.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Mathieu Poirier <mathieu.poirier@linaro.org> Cc: Mike Leach <mike.leach@linaro.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Paul Clarke <pc@us.ibm.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Riccardo Mancini <rickyman7@gmail.com> Cc: Stephane Eranian <eranian@google.com> Cc: Suzuki Poulouse <suzuki.poulose@arm.com> Cc: Vineet Singh <vineet.singh@intel.com> Cc: coresight@lists.linaro.org Cc: linux-arm-kernel@lists.infradead.org Cc: zhengjun.xing@intel.com Link: https://lore.kernel.org/r/20220105061351.120843-48-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent b57af1b commit ce37ab3

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

tools/perf/util/stat-display.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -327,24 +327,23 @@ static void print_metric_header(struct perf_stat_config *config,
327327
fprintf(os->fh, "%*s ", config->metric_only_len, unit);
328328
}
329329

330-
static int first_shadow_cpu(struct perf_stat_config *config,
331-
struct evsel *evsel, const struct aggr_cpu_id *id)
330+
static int first_shadow_cpu_map_idx(struct perf_stat_config *config,
331+
struct evsel *evsel, const struct aggr_cpu_id *id)
332332
{
333-
struct perf_cpu_map *cpus;
333+
struct perf_cpu_map *cpus = evsel__cpus(evsel);
334334
int cpu, idx;
335335

336336
if (config->aggr_mode == AGGR_NONE)
337-
return id->cpu;
337+
return perf_cpu_map__idx(cpus, id->cpu);
338338

339339
if (!config->aggr_get_id)
340340
return 0;
341341

342-
cpus = evsel__cpus(evsel);
343342
perf_cpu_map__for_each_cpu(cpu, idx, cpus) {
344343
struct aggr_cpu_id cpu_id = config->aggr_get_id(config, cpu);
345344

346345
if (aggr_cpu_id__equal(&cpu_id, id))
347-
return cpu;
346+
return idx;
348347
}
349348
return 0;
350349
}
@@ -503,7 +502,7 @@ static void printout(struct perf_stat_config *config, struct aggr_cpu_id id, int
503502
}
504503

505504
perf_stat__print_shadow_stats(config, counter, uval,
506-
first_shadow_cpu(config, counter, &id),
505+
first_shadow_cpu_map_idx(config, counter, &id),
507506
&out, &config->metric_events, st);
508507
if (!config->csv_output && !config->metric_only) {
509508
print_noise(config, counter, noise);
@@ -532,7 +531,7 @@ static void aggr_update_shadow(struct perf_stat_config *config,
532531
val += perf_counts(counter->counts, idx, 0)->val;
533532
}
534533
perf_stat__update_shadow_stats(counter, val,
535-
first_shadow_cpu(config, counter, &id),
534+
first_shadow_cpu_map_idx(config, counter, &id),
536535
&rt_stat);
537536
}
538537
}

0 commit comments

Comments
 (0)