OSDN Git Service

perf script: Use for each cpu to aid readability
authorIan Rogers <irogers@google.com>
Wed, 5 Jan 2022 06:13:35 +0000 (22:13 -0800)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 12 Jan 2022 17:28:22 +0000 (14:28 -0300)
Use perf_cpu_map__for_each_cpu() to help with readability.

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: James Clark <james.clark@arm.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-33-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-script.c

index c9b3002..f403191 100644 (file)
@@ -2115,8 +2115,7 @@ static struct scripting_ops       *scripting_ops;
 static void __process_stat(struct evsel *counter, u64 tstamp)
 {
        int nthreads = perf_thread_map__nr(counter->core.threads);
-       int ncpus = evsel__nr_cpus(counter);
-       int cpu, thread;
+       int idx, cpu, thread;
        static int header_printed;
 
        if (counter->core.system_wide)
@@ -2129,13 +2128,13 @@ static void __process_stat(struct evsel *counter, u64 tstamp)
        }
 
        for (thread = 0; thread < nthreads; thread++) {
-               for (cpu = 0; cpu < ncpus; cpu++) {
+               perf_cpu_map__for_each_cpu(cpu, idx, evsel__cpus(counter)) {
                        struct perf_counts_values *counts;
 
                        counts = perf_counts(counter->counts, cpu, thread);
 
                        printf("%3d %8d %15" PRIu64 " %15" PRIu64 " %15" PRIu64 " %15" PRIu64 " %s\n",
-                               counter->core.cpus->map[cpu],
+                               cpu,
                                perf_thread_map__pid(counter->core.threads, thread),
                                counts->val,
                                counts->ena,