perf stat: Support per-die aggregation

It is useful to aggregate counts per die. E.g. Uncore becomes die-scope
on Xeon Cascade Lake-AP.

Introduce a new option "--per-die" to support per-die aggregation.

The global id for each core has been changed to socket + die id + core
id. The global id for each die is socket + die id.

Add die information for per-core aggregation. The output of per-core
aggregation will be changed from "S0-C0" to "S0-D0-C0". Any scripts
which rely on the output format of per-core aggregation probably be
broken.

For 'perf stat record/report', there is no die information when
processing the old perf.data. The per-die result will be the same as
per-socket.

Committer notes:

Renamed 'die' variable to 'die_id' to fix the build in some systems:

    CC       /tmp/build/perf/builtin-script.o
  cc1: warnings being treated as errors
  builtin-stat.c: In function 'perf_env__get_die':
  builtin-stat.c:963: error: declaration of 'die' shadows a global declaration
  util/util.h:19: error: shadowed declaration is here
  mv: cannot stat `/tmp/build/perf/.builtin-stat.o.tmp': No such file or directory

Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Reviewed-by: Jiri Olsa <jolsa@kernel.org>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lkml.kernel.org/n/tip-bsnhx7vgsuu6ei307mw60mbj@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Kan Liang
2019-06-04 15:50:42 -07:00
committed by Arnaldo Carvalho de Melo
parent acae8b36cd
commit db5742b684
8 changed files with 177 additions and 18 deletions

View File

@@ -380,6 +380,39 @@ int cpu_map__get_die_id(int cpu)
return ret ?: value;
}
int cpu_map__get_die(struct cpu_map *map, int idx, void *data)
{
int cpu, die_id, s;
if (idx > map->nr)
return -1;
cpu = map->map[idx];
die_id = cpu_map__get_die_id(cpu);
/* There is no die_id on legacy system. */
if (die_id == -1)
die_id = 0;
s = cpu_map__get_socket(map, idx, data);
if (s == -1)
return -1;
/*
* Encode socket in bit range 15:8
* die_id is relative to socket, and
* we need a global id. So we combine
* socket + die id
*/
if (WARN_ONCE(die_id >> 8, "The die id number is too big.\n"))
return -1;
if (WARN_ONCE(s >> 8, "The socket id number is too big.\n"))
return -1;
return (s << 8) | (die_id & 0xff);
}
int cpu_map__get_core_id(int cpu)
{
int value, ret = cpu__get_topology_int(cpu, "core_id", &value);
@@ -388,7 +421,7 @@ int cpu_map__get_core_id(int cpu)
int cpu_map__get_core(struct cpu_map *map, int idx, void *data)
{
int cpu, s;
int cpu, s_die;
if (idx > map->nr)
return -1;
@@ -397,17 +430,22 @@ int cpu_map__get_core(struct cpu_map *map, int idx, void *data)
cpu = cpu_map__get_core_id(cpu);
s = cpu_map__get_socket(map, idx, data);
if (s == -1)
/* s_die is the combination of socket + die id */
s_die = cpu_map__get_die(map, idx, data);
if (s_die == -1)
return -1;
/*
* encode socket in upper 16 bits
* core_id is relative to socket, and
* encode socket in bit range 31:24
* encode die id in bit range 23:16
* core_id is relative to socket and die,
* we need a global id. So we combine
* socket+ core id
* socket + die id + core id
*/
return (s << 16) | (cpu & 0xffff);
if (WARN_ONCE(cpu >> 16, "The core id number is too big.\n"))
return -1;
return (s_die << 16) | (cpu & 0xffff);
}
int cpu_map__build_socket_map(struct cpu_map *cpus, struct cpu_map **sockp)
@@ -415,6 +453,11 @@ int cpu_map__build_socket_map(struct cpu_map *cpus, struct cpu_map **sockp)
return cpu_map__build_map(cpus, sockp, cpu_map__get_socket, NULL);
}
int cpu_map__build_die_map(struct cpu_map *cpus, struct cpu_map **diep)
{
return cpu_map__build_map(cpus, diep, cpu_map__get_die, NULL);
}
int cpu_map__build_core_map(struct cpu_map *cpus, struct cpu_map **corep)
{
return cpu_map__build_map(cpus, corep, cpu_map__get_core, NULL);