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

perf cpumap: Simplify equal function name

Rename cpu_map__compare_aggr_cpu_id() to aggr_cpu_id__equal(), the
cpu_map part of the name is misleading. Equal better describes the
function than compare.

Switch to const pointer rather than value as struct given the number of
variables in aggr_cpu_id().
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-14-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 63e0fa87
...@@ -171,7 +171,7 @@ int cpu_map__build_map(struct perf_cpu_map *cpus, struct cpu_aggr_map **res, ...@@ -171,7 +171,7 @@ int cpu_map__build_map(struct perf_cpu_map *cpus, struct cpu_aggr_map **res,
for (cpu = 0; cpu < nr; cpu++) { for (cpu = 0; cpu < nr; cpu++) {
s1 = f(cpu, data); s1 = f(cpu, data);
for (s2 = 0; s2 < c->nr; s2++) { for (s2 = 0; s2 < c->nr; s2++) {
if (cpu_map__compare_aggr_cpu_id(s1, c->map[s2])) if (aggr_cpu_id__equal(&s1, &c->map[s2]))
break; break;
} }
if (s2 == c->nr) { if (s2 == c->nr) {
...@@ -593,13 +593,13 @@ const struct perf_cpu_map *cpu_map__online(void) /* thread unsafe */ ...@@ -593,13 +593,13 @@ const struct perf_cpu_map *cpu_map__online(void) /* thread unsafe */
return online; return online;
} }
bool cpu_map__compare_aggr_cpu_id(struct aggr_cpu_id a, struct aggr_cpu_id b) bool aggr_cpu_id__equal(const struct aggr_cpu_id *a, const struct aggr_cpu_id *b)
{ {
return a.thread == b.thread && return a->thread == b->thread &&
a.node == b.node && a->node == b->node &&
a.socket == b.socket && a->socket == b->socket &&
a.die == b.die && a->die == b->die &&
a.core == b.core; a->core == b->core;
} }
bool cpu_map__aggr_cpu_id_is_empty(struct aggr_cpu_id a) bool cpu_map__aggr_cpu_id_is_empty(struct aggr_cpu_id a)
......
...@@ -67,7 +67,7 @@ int cpu_map__build_map(struct perf_cpu_map *cpus, struct cpu_aggr_map **res, ...@@ -67,7 +67,7 @@ int cpu_map__build_map(struct perf_cpu_map *cpus, struct cpu_aggr_map **res,
int cpu_map__cpu(struct perf_cpu_map *cpus, int idx); int cpu_map__cpu(struct perf_cpu_map *cpus, int idx);
bool cpu_map__has(struct perf_cpu_map *cpus, int cpu); bool cpu_map__has(struct perf_cpu_map *cpus, int cpu);
bool cpu_map__compare_aggr_cpu_id(struct aggr_cpu_id a, struct aggr_cpu_id b); bool aggr_cpu_id__equal(const struct aggr_cpu_id *a, const struct aggr_cpu_id *b);
bool cpu_map__aggr_cpu_id_is_empty(struct aggr_cpu_id a); bool cpu_map__aggr_cpu_id_is_empty(struct aggr_cpu_id a);
struct aggr_cpu_id cpu_map__empty_aggr_cpu_id(void); struct aggr_cpu_id cpu_map__empty_aggr_cpu_id(void);
......
...@@ -328,20 +328,22 @@ static void print_metric_header(struct perf_stat_config *config, ...@@ -328,20 +328,22 @@ static void print_metric_header(struct perf_stat_config *config,
} }
static int first_shadow_cpu(struct perf_stat_config *config, static int first_shadow_cpu(struct perf_stat_config *config,
struct evsel *evsel, struct aggr_cpu_id id) struct evsel *evsel, const struct aggr_cpu_id *id)
{ {
struct perf_cpu_map *cpus; struct perf_cpu_map *cpus;
int cpu, idx; int cpu, idx;
if (config->aggr_mode == AGGR_NONE) if (config->aggr_mode == AGGR_NONE)
return id.core; return id->core;
if (!config->aggr_get_id) if (!config->aggr_get_id)
return 0; return 0;
cpus = evsel__cpus(evsel); cpus = evsel__cpus(evsel);
perf_cpu_map__for_each_cpu(cpu, idx, cpus) { perf_cpu_map__for_each_cpu(cpu, idx, cpus) {
if (cpu_map__compare_aggr_cpu_id(config->aggr_get_id(config, cpu), id)) struct aggr_cpu_id cpu_id = config->aggr_get_id(config, cpu);
if (aggr_cpu_id__equal(&cpu_id, id))
return cpu; return cpu;
} }
return 0; return 0;
...@@ -501,7 +503,7 @@ static void printout(struct perf_stat_config *config, struct aggr_cpu_id id, int ...@@ -501,7 +503,7 @@ static void printout(struct perf_stat_config *config, struct aggr_cpu_id id, int
} }
perf_stat__print_shadow_stats(config, counter, uval, perf_stat__print_shadow_stats(config, counter, uval,
first_shadow_cpu(config, counter, id), first_shadow_cpu(config, counter, &id),
&out, &config->metric_events, st); &out, &config->metric_events, st);
if (!config->csv_output && !config->metric_only) { if (!config->csv_output && !config->metric_only) {
print_noise(config, counter, noise); print_noise(config, counter, noise);
...@@ -525,12 +527,12 @@ static void aggr_update_shadow(struct perf_stat_config *config, ...@@ -525,12 +527,12 @@ static void aggr_update_shadow(struct perf_stat_config *config,
val = 0; val = 0;
perf_cpu_map__for_each_cpu(cpu, idx, cpus) { perf_cpu_map__for_each_cpu(cpu, idx, cpus) {
s2 = config->aggr_get_id(config, cpu); s2 = config->aggr_get_id(config, cpu);
if (!cpu_map__compare_aggr_cpu_id(s2, id)) if (!aggr_cpu_id__equal(&s2, &id))
continue; continue;
val += perf_counts(counter->counts, idx, 0)->val; val += perf_counts(counter->counts, idx, 0)->val;
} }
perf_stat__update_shadow_stats(counter, val, perf_stat__update_shadow_stats(counter, val,
first_shadow_cpu(config, counter, id), first_shadow_cpu(config, counter, &id),
&rt_stat); &rt_stat);
} }
} }
...@@ -641,7 +643,7 @@ static void aggr_cb(struct perf_stat_config *config, ...@@ -641,7 +643,7 @@ static void aggr_cb(struct perf_stat_config *config,
struct perf_counts_values *counts; struct perf_counts_values *counts;
s2 = config->aggr_get_id(config, cpu); s2 = config->aggr_get_id(config, cpu);
if (!cpu_map__compare_aggr_cpu_id(s2, ad->id)) if (!aggr_cpu_id__equal(&s2, &ad->id))
continue; continue;
if (first) if (first)
ad->nr++; ad->nr++;
...@@ -1217,7 +1219,7 @@ static void print_percore_thread(struct perf_stat_config *config, ...@@ -1217,7 +1219,7 @@ static void print_percore_thread(struct perf_stat_config *config,
s2 = config->aggr_get_id(config, cpu); s2 = config->aggr_get_id(config, cpu);
for (s = 0; s < config->aggr_map->nr; s++) { for (s = 0; s < config->aggr_map->nr; s++) {
id = config->aggr_map->map[s]; id = config->aggr_map->map[s];
if (cpu_map__compare_aggr_cpu_id(s2, id)) if (aggr_cpu_id__equal(&s2, &id))
break; break;
} }
......
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