perf stat: Switch aggregation to use for_each loop
Tidy up the use of cpu and index to hopefully make the code less error prone. Avoid unused warnings with (void) which will be removed in a later patch. Reviewed-by: James Clark <james.clark@arm.com> Signed-off-by: Ian 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-5-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
committed by
Arnaldo Carvalho de Melo
parent
01843ca019
commit
a023283fad
@@ -330,8 +330,8 @@ 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, struct aggr_cpu_id id)
|
||||||
{
|
{
|
||||||
struct evlist *evlist = evsel->evlist;
|
struct perf_cpu_map *cpus;
|
||||||
int i;
|
int cpu, idx;
|
||||||
|
|
||||||
if (config->aggr_mode == AGGR_NONE)
|
if (config->aggr_mode == AGGR_NONE)
|
||||||
return id.core;
|
return id.core;
|
||||||
@@ -339,14 +339,11 @@ static int first_shadow_cpu(struct perf_stat_config *config,
|
|||||||
if (!config->aggr_get_id)
|
if (!config->aggr_get_id)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
for (i = 0; i < evsel__nr_cpus(evsel); i++) {
|
cpus = evsel__cpus(evsel);
|
||||||
int cpu2 = evsel__cpus(evsel)->map[i];
|
perf_cpu_map__for_each_cpu(cpu, idx, cpus) {
|
||||||
|
if (cpu_map__compare_aggr_cpu_id(config->aggr_get_id(config, cpus, idx),
|
||||||
if (cpu_map__compare_aggr_cpu_id(
|
id))
|
||||||
config->aggr_get_id(config, evlist->core.cpus, cpu2),
|
return cpu;
|
||||||
id)) {
|
|
||||||
return cpu2;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -516,20 +513,23 @@ static void printout(struct perf_stat_config *config, struct aggr_cpu_id id, int
|
|||||||
static void aggr_update_shadow(struct perf_stat_config *config,
|
static void aggr_update_shadow(struct perf_stat_config *config,
|
||||||
struct evlist *evlist)
|
struct evlist *evlist)
|
||||||
{
|
{
|
||||||
int cpu, s;
|
int cpu, idx, s;
|
||||||
struct aggr_cpu_id s2, id;
|
struct aggr_cpu_id s2, id;
|
||||||
u64 val;
|
u64 val;
|
||||||
struct evsel *counter;
|
struct evsel *counter;
|
||||||
|
struct perf_cpu_map *cpus;
|
||||||
|
|
||||||
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];
|
||||||
evlist__for_each_entry(evlist, counter) {
|
evlist__for_each_entry(evlist, counter) {
|
||||||
|
cpus = evsel__cpus(counter);
|
||||||
val = 0;
|
val = 0;
|
||||||
for (cpu = 0; cpu < evsel__nr_cpus(counter); cpu++) {
|
perf_cpu_map__for_each_cpu(cpu, idx, cpus) {
|
||||||
s2 = config->aggr_get_id(config, evsel__cpus(counter), cpu);
|
(void)cpu;
|
||||||
|
s2 = config->aggr_get_id(config, cpus, idx);
|
||||||
if (!cpu_map__compare_aggr_cpu_id(s2, id))
|
if (!cpu_map__compare_aggr_cpu_id(s2, id))
|
||||||
continue;
|
continue;
|
||||||
val += perf_counts(counter->counts, cpu, 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),
|
||||||
@@ -634,18 +634,21 @@ static void aggr_cb(struct perf_stat_config *config,
|
|||||||
struct evsel *counter, void *data, bool first)
|
struct evsel *counter, void *data, bool first)
|
||||||
{
|
{
|
||||||
struct aggr_data *ad = data;
|
struct aggr_data *ad = data;
|
||||||
int cpu;
|
int idx, cpu;
|
||||||
|
struct perf_cpu_map *cpus;
|
||||||
struct aggr_cpu_id s2;
|
struct aggr_cpu_id s2;
|
||||||
|
|
||||||
for (cpu = 0; cpu < evsel__nr_cpus(counter); cpu++) {
|
cpus = evsel__cpus(counter);
|
||||||
|
perf_cpu_map__for_each_cpu(cpu, idx, cpus) {
|
||||||
struct perf_counts_values *counts;
|
struct perf_counts_values *counts;
|
||||||
|
|
||||||
s2 = config->aggr_get_id(config, evsel__cpus(counter), cpu);
|
(void)cpu;
|
||||||
|
s2 = config->aggr_get_id(config, cpus, idx);
|
||||||
if (!cpu_map__compare_aggr_cpu_id(s2, ad->id))
|
if (!cpu_map__compare_aggr_cpu_id(s2, ad->id))
|
||||||
continue;
|
continue;
|
||||||
if (first)
|
if (first)
|
||||||
ad->nr++;
|
ad->nr++;
|
||||||
counts = perf_counts(counter->counts, cpu, 0);
|
counts = perf_counts(counter->counts, idx, 0);
|
||||||
/*
|
/*
|
||||||
* When any result is bad, make them all to give
|
* When any result is bad, make them all to give
|
||||||
* consistent output in interval mode.
|
* consistent output in interval mode.
|
||||||
@@ -1208,10 +1211,13 @@ static void print_percore_thread(struct perf_stat_config *config,
|
|||||||
{
|
{
|
||||||
int s;
|
int s;
|
||||||
struct aggr_cpu_id s2, id;
|
struct aggr_cpu_id s2, id;
|
||||||
|
struct perf_cpu_map *cpus;
|
||||||
bool first = true;
|
bool first = true;
|
||||||
|
int idx, cpu;
|
||||||
|
|
||||||
for (int i = 0; i < evsel__nr_cpus(counter); i++) {
|
cpus = evsel__cpus(counter);
|
||||||
s2 = config->aggr_get_id(config, evsel__cpus(counter), i);
|
perf_cpu_map__for_each_cpu(cpu, idx, cpus) {
|
||||||
|
s2 = config->aggr_get_id(config, cpus, idx);
|
||||||
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 (cpu_map__compare_aggr_cpu_id(s2, id))
|
||||||
@@ -1220,7 +1226,7 @@ static void print_percore_thread(struct perf_stat_config *config,
|
|||||||
|
|
||||||
print_counter_aggrdata(config, counter, s,
|
print_counter_aggrdata(config, counter, s,
|
||||||
prefix, false,
|
prefix, false,
|
||||||
&first, i);
|
&first, cpu);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user