Commit 2b07e5cc authored by Kan Liang's avatar Kan Liang Committed by Luis Henriques

perf stat: Get correct cpu id for print_aggr

commit 601083cf upstream.

print_aggr() fails to print per-core/per-socket statistics after commit
582ec082 ("perf stat: Fix per-socket output bug for uncore events")
if events have differnt cpus. Because in print_aggr(), aggr_get_id needs
index (not cpu id) to find core/pkg id. Also, evsel cpu maps should be
used to get aggregated id.

Here is an example:

Counting events cycles,uncore_imc_0/cas_count_read/. (Uncore event has
cpumask 0,18)

  $ perf stat -e cycles,uncore_imc_0/cas_count_read/ -C0,18 --per-core sleep 2

Without this patch, it failes to get CPU 18 result.

   Performance counter stats for 'CPU(s) 0,18':

  S0-C0           1            7526851      cycles
  S0-C0           1               1.05 MiB  uncore_imc_0/cas_count_read/
  S1-C0           0      <not counted>      cycles
  S1-C0           0      <not counted> MiB  uncore_imc_0/cas_count_read/

With this patch, it can get both CPU0 and CPU18 result.

   Performance counter stats for 'CPU(s) 0,18':

  S0-C0           1            6327768      cycles
  S0-C0           1               0.47 MiB  uncore_imc_0/cas_count_read/
  S1-C0           1             330228      cycles
  S1-C0           1               0.29 MiB  uncore_imc_0/cas_count_read/
Signed-off-by: default avatarKan Liang <kan.liang@intel.com>
Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
Acked-by: default avatarStephane Eranian <eranian@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Fixes: 582ec082 ("perf stat: Fix per-socket output bug for uncore events")
Link: http://lkml.kernel.org/r/1435820925-51091-1-git-send-email-kan.liang@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: default avatarLuis Henriques <luis.henriques@canonical.com>
parent 96351f5e
...@@ -1115,7 +1115,7 @@ static void abs_printout(int cpu, int nr, struct perf_evsel *evsel, double avg) ...@@ -1115,7 +1115,7 @@ static void abs_printout(int cpu, int nr, struct perf_evsel *evsel, double avg)
static void print_aggr(char *prefix) static void print_aggr(char *prefix)
{ {
struct perf_evsel *counter; struct perf_evsel *counter;
int cpu, cpu2, s, s2, id, nr; int cpu, s, s2, id, nr;
double uval; double uval;
u64 ena, run, val; u64 ena, run, val;
...@@ -1128,8 +1128,7 @@ static void print_aggr(char *prefix) ...@@ -1128,8 +1128,7 @@ static void print_aggr(char *prefix)
val = ena = run = 0; val = ena = run = 0;
nr = 0; nr = 0;
for (cpu = 0; cpu < perf_evsel__nr_cpus(counter); cpu++) { for (cpu = 0; cpu < perf_evsel__nr_cpus(counter); cpu++) {
cpu2 = perf_evsel__cpus(counter)->map[cpu]; s2 = aggr_get_id(perf_evsel__cpus(counter), cpu);
s2 = aggr_get_id(evsel_list->cpus, cpu2);
if (s2 != id) if (s2 != id)
continue; continue;
val += counter->counts->cpu[cpu].val; val += counter->counts->cpu[cpu].val;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment