Re: [PATCH v2 30/48] perf stat: Rename aggr_data cpu to imply it's an index

From: Namhyung Kim
Date: Tue Dec 28 2021 - 19:37:14 EST


On Wed, Dec 22, 2021 at 11:47 PM Ian Rogers <irogers@xxxxxxxxxx> wrote:
>
> Trying to make cpu maps less error prone.
>
> Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
> ---
> tools/perf/util/python.c | 2 +-
> tools/perf/util/stat-display.c | 10 +++++-----
> 2 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c
> index 563a9ba8954f..4b510a1f27d4 100644
> --- a/tools/perf/util/python.c
> +++ b/tools/perf/util/python.c
> @@ -1057,7 +1057,7 @@ static struct mmap *get_md(struct evlist *evlist, int cpu)
> for (i = 0; i < evlist->core.nr_mmaps; i++) {
> struct mmap *md = &evlist->mmap[i];
>
> - if (md->core.cpu == cpu)
> + if (md->core.cpu_map_idx == cpu)

It doesn't seem to belong to this change..

Thanks,
Namhyung


> return md;
> }
>
> diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c
> index 821511ba22cc..4f93591aaa76 100644
> --- a/tools/perf/util/stat-display.c
> +++ b/tools/perf/util/stat-display.c
> @@ -626,7 +626,7 @@ struct aggr_data {
> u64 ena, run, val;
> struct aggr_cpu_id id;
> int nr;
> - int cpu;
> + int cpu_map_idx;
> };
>
> static void aggr_cb(struct perf_stat_config *config,
> @@ -878,9 +878,9 @@ static void counter_cb(struct perf_stat_config *config __maybe_unused,
> {
> struct aggr_data *ad = data;
>
> - ad->val += perf_counts(counter->counts, ad->cpu, 0)->val;
> - ad->ena += perf_counts(counter->counts, ad->cpu, 0)->ena;
> - ad->run += perf_counts(counter->counts, ad->cpu, 0)->run;
> + ad->val += perf_counts(counter->counts, ad->cpu_map_idx, 0)->val;
> + ad->ena += perf_counts(counter->counts, ad->cpu_map_idx, 0)->ena;
> + ad->run += perf_counts(counter->counts, ad->cpu_map_idx, 0)->run;
> }
>
> /*
> @@ -897,7 +897,7 @@ static void print_counter(struct perf_stat_config *config,
> struct aggr_cpu_id id;
>
> for (cpu = 0; cpu < evsel__nr_cpus(counter); cpu++) {
> - struct aggr_data ad = { .cpu = cpu };
> + struct aggr_data ad = { .cpu_map_idx = cpu };
>
> if (!collect_data(config, counter, counter_cb, &ad))
> return;
> --
> 2.34.1.307.g9b7440fafd-goog
>