Commit 4e90e5cc authored by Ian Rogers's avatar Ian Rogers Committed by Arnaldo Carvalho de Melo

perf cpumap: Remove map from function names that don't use a map

Move to the cpu name and document for consistency.
Reviewed-by: default avatarJames Clark <james.clark@arm.com>
Signed-off-by: default avatarIan 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: 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-17-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 194a3a20
...@@ -126,7 +126,7 @@ static int cpu__get_topology_int(int cpu, const char *name, int *value) ...@@ -126,7 +126,7 @@ static int cpu__get_topology_int(int cpu, const char *name, int *value)
return sysfs__read_int(path, value); return sysfs__read_int(path, value);
} }
int cpu_map__get_socket_id(int cpu) int cpu__get_socket_id(int cpu)
{ {
int value, ret = cpu__get_topology_int(cpu, "physical_package_id", &value); int value, ret = cpu__get_topology_int(cpu, "physical_package_id", &value);
return ret ?: value; return ret ?: value;
...@@ -136,7 +136,7 @@ struct aggr_cpu_id cpu_map__get_socket_aggr_by_cpu(int cpu, void *data __maybe_u ...@@ -136,7 +136,7 @@ struct aggr_cpu_id cpu_map__get_socket_aggr_by_cpu(int cpu, void *data __maybe_u
{ {
struct aggr_cpu_id id = aggr_cpu_id__empty(); struct aggr_cpu_id id = aggr_cpu_id__empty();
id.socket = cpu_map__get_socket_id(cpu); id.socket = cpu__get_socket_id(cpu);
return id; return id;
} }
...@@ -190,7 +190,7 @@ int cpu_map__build_map(struct perf_cpu_map *cpus, struct cpu_aggr_map **res, ...@@ -190,7 +190,7 @@ int cpu_map__build_map(struct perf_cpu_map *cpus, struct cpu_aggr_map **res,
return 0; return 0;
} }
int cpu_map__get_die_id(int cpu) int cpu__get_die_id(int cpu)
{ {
int value, ret = cpu__get_topology_int(cpu, "die_id", &value); int value, ret = cpu__get_topology_int(cpu, "die_id", &value);
...@@ -202,7 +202,7 @@ struct aggr_cpu_id cpu_map__get_die_aggr_by_cpu(int cpu, void *data) ...@@ -202,7 +202,7 @@ struct aggr_cpu_id cpu_map__get_die_aggr_by_cpu(int cpu, void *data)
struct aggr_cpu_id id; struct aggr_cpu_id id;
int die; int die;
die = cpu_map__get_die_id(cpu); die = cpu__get_die_id(cpu);
/* There is no die_id on legacy system. */ /* There is no die_id on legacy system. */
if (die == -1) if (die == -1)
die = 0; die = 0;
...@@ -220,7 +220,7 @@ struct aggr_cpu_id cpu_map__get_die_aggr_by_cpu(int cpu, void *data) ...@@ -220,7 +220,7 @@ struct aggr_cpu_id cpu_map__get_die_aggr_by_cpu(int cpu, void *data)
return id; return id;
} }
int cpu_map__get_core_id(int cpu) int cpu__get_core_id(int cpu)
{ {
int value, ret = cpu__get_topology_int(cpu, "core_id", &value); int value, ret = cpu__get_topology_int(cpu, "core_id", &value);
return ret ?: value; return ret ?: value;
...@@ -229,7 +229,7 @@ int cpu_map__get_core_id(int cpu) ...@@ -229,7 +229,7 @@ int cpu_map__get_core_id(int cpu)
struct aggr_cpu_id cpu_map__get_core_aggr_by_cpu(int cpu, void *data) struct aggr_cpu_id cpu_map__get_core_aggr_by_cpu(int cpu, void *data)
{ {
struct aggr_cpu_id id; struct aggr_cpu_id id;
int core = cpu_map__get_core_id(cpu); int core = cpu__get_core_id(cpu);
/* cpu_map__get_die returns a struct with socket and die set*/ /* cpu_map__get_die returns a struct with socket and die set*/
id = cpu_map__get_die_aggr_by_cpu(cpu, data); id = cpu_map__get_die_aggr_by_cpu(cpu, data);
......
...@@ -39,11 +39,8 @@ struct perf_cpu_map *cpu_map__new_data(struct perf_record_cpu_map_data *data); ...@@ -39,11 +39,8 @@ struct perf_cpu_map *cpu_map__new_data(struct perf_record_cpu_map_data *data);
size_t cpu_map__snprint(struct perf_cpu_map *map, char *buf, size_t size); size_t cpu_map__snprint(struct perf_cpu_map *map, char *buf, size_t size);
size_t cpu_map__snprint_mask(struct perf_cpu_map *map, char *buf, size_t size); size_t cpu_map__snprint_mask(struct perf_cpu_map *map, char *buf, size_t size);
size_t cpu_map__fprintf(struct perf_cpu_map *map, FILE *fp); size_t cpu_map__fprintf(struct perf_cpu_map *map, FILE *fp);
int cpu_map__get_socket_id(int cpu);
struct aggr_cpu_id cpu_map__get_socket_aggr_by_cpu(int cpu, void *data); struct aggr_cpu_id cpu_map__get_socket_aggr_by_cpu(int cpu, void *data);
int cpu_map__get_die_id(int cpu);
struct aggr_cpu_id cpu_map__get_die_aggr_by_cpu(int cpu, void *data); struct aggr_cpu_id cpu_map__get_die_aggr_by_cpu(int cpu, void *data);
int cpu_map__get_core_id(int cpu);
struct aggr_cpu_id cpu_map__get_core_aggr_by_cpu(int cpu, void *data); struct aggr_cpu_id cpu_map__get_core_aggr_by_cpu(int cpu, void *data);
struct aggr_cpu_id cpu_map__get_node_aggr_by_cpu(int cpu, void *data); struct aggr_cpu_id cpu_map__get_node_aggr_by_cpu(int cpu, void *data);
int cpu_map__build_socket_map(struct perf_cpu_map *cpus, struct cpu_aggr_map **sockp); int cpu_map__build_socket_map(struct perf_cpu_map *cpus, struct cpu_aggr_map **sockp);
...@@ -62,6 +59,22 @@ int cpu__max_present_cpu(void); ...@@ -62,6 +59,22 @@ int cpu__max_present_cpu(void);
* /sys/devices/system/node/nodeX for the given CPU. * /sys/devices/system/node/nodeX for the given CPU.
*/ */
int cpu__get_node(int cpu); int cpu__get_node(int cpu);
/**
* cpu__get_socket_id - Returns the socket number as read from
* /sys/devices/system/cpu/cpuX/topology/physical_package_id for the given CPU.
*/
int cpu__get_socket_id(int cpu);
/**
* cpu__get_die_id - Returns the die id as read from
* /sys/devices/system/cpu/cpuX/topology/die_id for the given CPU.
*/
int cpu__get_die_id(int cpu);
/**
* cpu__get_core_id - Returns the core id as read from
* /sys/devices/system/cpu/cpuX/topology/core_id for the given CPU.
*/
int cpu__get_core_id(int cpu);
int cpu_map__build_map(struct perf_cpu_map *cpus, struct cpu_aggr_map **res, int cpu_map__build_map(struct perf_cpu_map *cpus, struct cpu_aggr_map **res,
struct aggr_cpu_id (*f)(int cpu, void *data), struct aggr_cpu_id (*f)(int cpu, void *data),
......
...@@ -302,9 +302,9 @@ int perf_env__read_cpu_topology_map(struct perf_env *env) ...@@ -302,9 +302,9 @@ int perf_env__read_cpu_topology_map(struct perf_env *env)
return -ENOMEM; return -ENOMEM;
for (cpu = 0; cpu < nr_cpus; ++cpu) { for (cpu = 0; cpu < nr_cpus; ++cpu) {
env->cpu[cpu].core_id = cpu_map__get_core_id(cpu); env->cpu[cpu].core_id = cpu__get_core_id(cpu);
env->cpu[cpu].socket_id = cpu_map__get_socket_id(cpu); env->cpu[cpu].socket_id = cpu__get_socket_id(cpu);
env->cpu[cpu].die_id = cpu_map__get_die_id(cpu); env->cpu[cpu].die_id = cpu__get_die_id(cpu);
} }
env->nr_cpus_avail = nr_cpus; env->nr_cpus_avail = nr_cpus;
......
...@@ -328,7 +328,7 @@ static int check_per_pkg(struct evsel *counter, ...@@ -328,7 +328,7 @@ static int check_per_pkg(struct evsel *counter,
if (!(vals->run && vals->ena)) if (!(vals->run && vals->ena))
return 0; return 0;
s = cpu_map__get_socket_id(cpu); s = cpu__get_socket_id(cpu);
if (s < 0) if (s < 0)
return -1; return -1;
...@@ -336,7 +336,7 @@ static int check_per_pkg(struct evsel *counter, ...@@ -336,7 +336,7 @@ static int check_per_pkg(struct evsel *counter,
* On multi-die system, die_id > 0. On no-die system, die_id = 0. * On multi-die system, die_id > 0. On no-die system, die_id = 0.
* We use hashmap(socket, die) to check the used socket+die pair. * We use hashmap(socket, die) to check the used socket+die pair.
*/ */
d = cpu_map__get_die_id(cpu); d = cpu__get_die_id(cpu);
if (d < 0) if (d < 0)
return -1; return -1;
......
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