[PATCH v2 25/48] perf stat-display: Avoid use of core for CPU.

Namhyung Kim namhyung at kernel.org
Tue Dec 28 16:09:41 PST 2021


On Wed, Dec 22, 2021 at 11:47 PM Ian Rogers <irogers at google.com> wrote:
>
> Correct use of cpumap index in print_no_aggr_metric.
>
> Signed-off-by: Ian Rogers <irogers at google.com>
> ---
[SNIP]
> @@ -924,29 +921,32 @@ static void print_no_aggr_metric(struct perf_stat_config *config,
>                                  struct evlist *evlist,
>                                  char *prefix)
>  {
> -       int cpu;
> -       int nrcpus = 0;
> -       struct evsel *counter;
> -       u64 ena, run, val;
> -       double uval;
> -       struct aggr_cpu_id id;
> +       int cpu, nrcpus;
>
>         nrcpus = evlist->core.cpus->nr;
>         for (cpu = 0; cpu < nrcpus; cpu++) {
> +               struct evsel *counter;
>                 bool first = true;
>
>                 if (prefix)
>                         fputs(prefix, config->output);
>                 evlist__for_each_entry(evlist, counter) {
> -                       id = aggr_cpu_id__empty();
> -                       id.core = cpu;
> +                       u64 ena, run, val;
> +                       double uval;
> +                       struct aggr_cpu_id id;
> +                       int idx = perf_cpu_map__idx(evsel__cpus(counter), cpu);

Not sure about this.  Here the 'cpu' is an index for the
evlist->core.cpus, not a CPU number.  But the
perf_cpu_map__idx() requires a CPU number, right?

Thanks,
Namhyung


> +
> +                       if (idx < 0)
> +                               continue;
> +
> +                       id = aggr_cpu_id__cpu(cpu, /*data=*/NULL);
>                         if (first) {
>                                 aggr_printout(config, counter, id, 0);
>                                 first = false;
>                         }
> -                       val = perf_counts(counter->counts, cpu, 0)->val;
> -                       ena = perf_counts(counter->counts, cpu, 0)->ena;
> -                       run = perf_counts(counter->counts, cpu, 0)->run;
> +                       val = perf_counts(counter->counts, idx, 0)->val;
> +                       ena = perf_counts(counter->counts, idx, 0)->ena;
> +                       run = perf_counts(counter->counts, idx, 0)->run;
>
>                         uval = val * counter->scale;
>                         printout(config, id, 0, counter, uval, prefix,
> --
> 2.34.1.307.g9b7440fafd-goog
>



More information about the linux-arm-kernel mailing list