Re: [PATCH 2/3] perf stat: Support per-die aggregation
From: Jiri Olsa
Date: Tue May 28 2019 - 05:03:42 EST
On Thu, May 23, 2019 at 01:41:20PM -0700, kan.liang@xxxxxxxxxxxxxxx wrote:
SNIP
> if (cpu_map__build_core_map(evsel_list->cpus, &stat_config.aggr_map)) {
> perror("cannot build core map");
> @@ -936,21 +957,41 @@ static int perf_env__get_socket(struct cpu_map *map, int idx, void *data)
> return cpu == -1 ? -1 : env->cpu[cpu].socket_id;
> }
>
> +static int perf_env__get_die(struct cpu_map *map, int idx, void *data)
> +{
> + struct perf_env *env = data;
> + int die = -1, cpu = perf_env__get_cpu(env, map, idx);
> +
> + if (cpu != -1) {
> + /*
> + * Encode socket in upper 8 bits
> + * die_id is relative to socket,
> + * we need a global id. So we combine
> + * socket + die id
> + */
> + die = (env->cpu[cpu].socket_id << 8) |
> + (env->cpu[cpu].die_id & 0xff);
> + }
> +
> + return die;
> +}
> +
> static int perf_env__get_core(struct cpu_map *map, int idx, void *data)
> {
> struct perf_env *env = data;
> int core = -1, cpu = perf_env__get_cpu(env, map, idx);
>
> if (cpu != -1) {
> - int socket_id = env->cpu[cpu].socket_id;
> -
> /*
> - * Encode socket in upper 16 bits
> - * core_id is relative to socket, and
> + * Encode socket in upper 24 bits
> + * encode die id in upper 16 bits
> + * core_id is relative to socket and die,
> * we need a global id. So we combine
> - * socket + core id.
> + * socket + die id + core id
> */
> - core = (socket_id << 16) | (env->cpu[cpu].core_id & 0xffff);
> + core = (env->cpu[cpu].socket_id << 24) |
> + (env->cpu[cpu].die_id << 16) |
> + (env->cpu[cpu].core_id & 0xffff);
I guess we're still safe with 1 byte for socket and die id,
but could we still check the size fits, and warn and bail
out otherwise?
thanks,
jirka