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

perf cpumap: Switch cpu_map__build_map() to cpu function

Avoid error prone cpu_map + idx variant. Remove now unused functions.

Committer notes:

Remove by now unused perf_env__get_cpu().
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-7-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 88031a0d
......@@ -1477,22 +1477,6 @@ static void perf_stat__exit_aggr_mode(void)
stat_config.cpus_aggr_map = NULL;
}
static inline int perf_env__get_cpu(void *data, struct perf_cpu_map *map, int idx)
{
struct perf_env *env = data;
int cpu;
if (idx > map->nr)
return -1;
cpu = map->map[idx];
if (cpu >= env->nr_cpus_avail)
return -1;
return cpu;
}
static struct aggr_cpu_id perf_env__get_socket_aggr_by_cpu(int cpu, void *data)
{
struct perf_env *env = data;
......@@ -1504,11 +1488,6 @@ static struct aggr_cpu_id perf_env__get_socket_aggr_by_cpu(int cpu, void *data)
return id;
}
static struct aggr_cpu_id perf_env__get_socket(struct perf_cpu_map *map, int idx, void *data)
{
return perf_env__get_socket_aggr_by_cpu(perf_env__get_cpu(data, map, idx), data);
}
static struct aggr_cpu_id perf_env__get_die_aggr_by_cpu(int cpu, void *data)
{
struct perf_env *env = data;
......@@ -1527,11 +1506,6 @@ static struct aggr_cpu_id perf_env__get_die_aggr_by_cpu(int cpu, void *data)
return id;
}
static struct aggr_cpu_id perf_env__get_die(struct perf_cpu_map *map, int idx, void *data)
{
return perf_env__get_die_aggr_by_cpu(perf_env__get_cpu(data, map, idx), data);
}
static struct aggr_cpu_id perf_env__get_core_aggr_by_cpu(int cpu, void *data)
{
struct perf_env *env = data;
......@@ -1551,11 +1525,6 @@ static struct aggr_cpu_id perf_env__get_core_aggr_by_cpu(int cpu, void *data)
return id;
}
static struct aggr_cpu_id perf_env__get_core(struct perf_cpu_map *map, int idx, void *data)
{
return perf_env__get_core_aggr_by_cpu(perf_env__get_cpu(data, map, idx), data);
}
static struct aggr_cpu_id perf_env__get_node_aggr_by_cpu(int cpu, void *data)
{
struct aggr_cpu_id id = cpu_map__empty_aggr_cpu_id();
......@@ -1564,33 +1533,28 @@ static struct aggr_cpu_id perf_env__get_node_aggr_by_cpu(int cpu, void *data)
return id;
}
static struct aggr_cpu_id perf_env__get_node(struct perf_cpu_map *map, int idx, void *data)
{
return perf_env__get_node_aggr_by_cpu(perf_env__get_cpu(data, map, idx), data);
}
static int perf_env__build_socket_map(struct perf_env *env, struct perf_cpu_map *cpus,
struct cpu_aggr_map **sockp)
{
return cpu_map__build_map(cpus, sockp, perf_env__get_socket, env);
return cpu_map__build_map(cpus, sockp, perf_env__get_socket_aggr_by_cpu, env);
}
static int perf_env__build_die_map(struct perf_env *env, struct perf_cpu_map *cpus,
struct cpu_aggr_map **diep)
{
return cpu_map__build_map(cpus, diep, perf_env__get_die, env);
return cpu_map__build_map(cpus, diep, perf_env__get_die_aggr_by_cpu, env);
}
static int perf_env__build_core_map(struct perf_env *env, struct perf_cpu_map *cpus,
struct cpu_aggr_map **corep)
{
return cpu_map__build_map(cpus, corep, perf_env__get_core, env);
return cpu_map__build_map(cpus, corep, perf_env__get_core_aggr_by_cpu, env);
}
static int perf_env__build_node_map(struct perf_env *env, struct perf_cpu_map *cpus,
struct cpu_aggr_map **nodep)
{
return cpu_map__build_map(cpus, nodep, perf_env__get_node, env);
return cpu_map__build_map(cpus, nodep, perf_env__get_node_aggr_by_cpu, env);
}
static struct aggr_cpu_id perf_stat__get_socket_file(struct perf_stat_config *config __maybe_unused,
......
......@@ -163,7 +163,7 @@ static int cmp_aggr_cpu_id(const void *a_pointer, const void *b_pointer)
}
int cpu_map__build_map(struct perf_cpu_map *cpus, struct cpu_aggr_map **res,
struct aggr_cpu_id (*f)(struct perf_cpu_map *map, int cpu, void *data),
struct aggr_cpu_id (*f)(int cpu, void *data),
void *data)
{
int nr = cpus->nr;
......@@ -178,7 +178,7 @@ int cpu_map__build_map(struct perf_cpu_map *cpus, struct cpu_aggr_map **res,
c->nr = 0;
for (cpu = 0; cpu < nr; cpu++) {
s1 = f(cpus, cpu, data);
s1 = f(cpu, data);
for (s2 = 0; s2 < c->nr; s2++) {
if (cpu_map__compare_aggr_cpu_id(s1, c->map[s2]))
break;
......@@ -290,22 +290,22 @@ struct aggr_cpu_id cpu_map__get_node(struct perf_cpu_map *map, int idx, void *da
int cpu_map__build_socket_map(struct perf_cpu_map *cpus, struct cpu_aggr_map **sockp)
{
return cpu_map__build_map(cpus, sockp, cpu_map__get_socket, NULL);
return cpu_map__build_map(cpus, sockp, cpu_map__get_socket_aggr_by_cpu, NULL);
}
int cpu_map__build_die_map(struct perf_cpu_map *cpus, struct cpu_aggr_map **diep)
{
return cpu_map__build_map(cpus, diep, cpu_map__get_die, NULL);
return cpu_map__build_map(cpus, diep, cpu_map__get_die_aggr_by_cpu, NULL);
}
int cpu_map__build_core_map(struct perf_cpu_map *cpus, struct cpu_aggr_map **corep)
{
return cpu_map__build_map(cpus, corep, cpu_map__get_core, NULL);
return cpu_map__build_map(cpus, corep, cpu_map__get_core_aggr_by_cpu, NULL);
}
int cpu_map__build_node_map(struct perf_cpu_map *cpus, struct cpu_aggr_map **numap)
{
return cpu_map__build_map(cpus, numap, cpu_map__get_node, NULL);
return cpu_map__build_map(cpus, numap, cpu_map__get_node_aggr_by_cpu, NULL);
}
/* setup simple routines to easily access node numbers given a cpu number */
......
......@@ -63,7 +63,7 @@ int cpu__max_present_cpu(void);
int cpu__get_node(int cpu);
int cpu_map__build_map(struct perf_cpu_map *cpus, struct cpu_aggr_map **res,
struct aggr_cpu_id (*f)(struct perf_cpu_map *map, int cpu, void *data),
struct aggr_cpu_id (*f)(int cpu, void *data),
void *data);
int cpu_map__cpu(struct perf_cpu_map *cpus, int idx);
......
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