Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf pmu: Move pmu_metrics_table__find and remove ARM override

Move pmu_metrics_table__find() to the jevents.py generated pmu-events.c
and remove indirection override for ARM.

The movement removes perf_pmu__find_metrics_table that exists to enable
the ARM override.

The ARM override isn't necessary as just the CPUID, not PMU, is used in
the metric table lookup.

On non-ARM the CPU argument is just ignored for the CPUID, for ARM -1 is
passed so that the CPUID for the first logical CPU is read.

Reviewed-by: James Clark <james.clark@linaro.org>
Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Xu Yang <xu.yang_2@nxp.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Albert Ou <aou@eecs.berkeley.edu>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexandre Ghiti <alexghiti@rivosinc.com>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Ben Zong-You Xie <ben717@andestech.com>
Cc: Benjamin Gray <bgray@linux.ibm.com>
Cc: Bibo Mao <maobibo@loongson.cn>
Cc: Clément Le Goffic <clement.legoffic@foss.st.com>
Cc: Dima Kogan <dima@secretsauce.net>
Cc: Dr. David Alan Gilbert <linux@treblig.org>
Cc: Huacai Chen <chenhuacai@kernel.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Leo Yan <leo.yan@linux.dev>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mike Leach <mike.leach@linaro.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Paul Walmsley <paul.walmsley@sifive.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: Sandipan Das <sandipan.das@amd.com>
Cc: Will Deacon <will@kernel.org>
Cc: Yicong Yang <yangyicong@hisilicon.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-riscv@lists.infradead.org
Link: https://lore.kernel.org/r/20241107162035.52206-9-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Ian Rogers and committed by
Arnaldo Carvalho de Melo
8f997865 0434410f

+9 -39
-20
tools/perf/arch/arm64/util/pmu.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 3 - #include <internal/cpumap.h> 4 - #include "../../../util/cpumap.h" 5 - #include "../../../util/header.h" 6 3 #include "../../../util/pmu.h" 7 4 #include "../../../util/pmus.h" 8 5 #include "../../../util/tool_pmu.h" 9 6 #include <api/fs/fs.h> 10 - #include <math.h> 11 - 12 - const struct pmu_metrics_table *pmu_metrics_table__find(void) 13 - { 14 - struct perf_pmu *pmu; 15 - 16 - /* Metrics aren't currently supported on heterogeneous Arm systems */ 17 - if (perf_pmus__num_core_pmus() > 1) 18 - return NULL; 19 - 20 - /* Doesn't matter which one here because they'll all be the same */ 21 - pmu = perf_pmus__find_core_pmu(); 22 - if (pmu) 23 - return perf_pmu__find_metrics_table(pmu); 24 - 25 - return NULL; 26 - } 27 7 28 8 u64 tool_pmu__cpu_slots_per_cycle(void) 29 9 {
+4 -6
tools/perf/pmu-events/empty-pmu-events.c
··· 587 587 return NULL; 588 588 } 589 589 590 - const struct pmu_metrics_table *perf_pmu__find_metrics_table(struct perf_pmu *pmu) 590 + const struct pmu_metrics_table *pmu_metrics_table__find(void) 591 591 { 592 - const struct pmu_events_map *map = map_for_pmu(pmu); 592 + struct perf_cpu cpu = {-1}; 593 + const struct pmu_events_map *map = map_for_cpu(cpu); 593 594 594 - if (!map) 595 - return NULL; 596 - 597 - return &map->metric_table; 595 + return map ? &map->metric_table : NULL; 598 596 } 599 597 600 598 const struct pmu_events_table *find_core_events_table(const char *arch, const char *cpuid)
+4 -6
tools/perf/pmu-events/jevents.py
··· 1103 1103 return NULL; 1104 1104 } 1105 1105 1106 - const struct pmu_metrics_table *perf_pmu__find_metrics_table(struct perf_pmu *pmu) 1106 + const struct pmu_metrics_table *pmu_metrics_table__find(void) 1107 1107 { 1108 - const struct pmu_events_map *map = map_for_pmu(pmu); 1108 + struct perf_cpu cpu = {-1}; 1109 + const struct pmu_events_map *map = map_for_cpu(cpu); 1109 1110 1110 - if (!map) 1111 - return NULL; 1112 - 1113 - return &map->metric_table; 1111 + return map ? &map->metric_table : NULL; 1114 1112 } 1115 1113 1116 1114 const struct pmu_events_table *find_core_events_table(const char *arch, const char *cpuid)
+1 -1
tools/perf/pmu-events/pmu-events.h
··· 103 103 void *data); 104 104 105 105 const struct pmu_events_table *perf_pmu__find_events_table(struct perf_pmu *pmu); 106 - const struct pmu_metrics_table *perf_pmu__find_metrics_table(struct perf_pmu *pmu); 106 + const struct pmu_metrics_table *pmu_metrics_table__find(void); 107 107 const struct pmu_events_table *find_core_events_table(const char *arch, const char *cpuid); 108 108 const struct pmu_metrics_table *find_core_metrics_table(const char *arch, const char *cpuid); 109 109 int pmu_for_each_core_event(pmu_event_iter_fn fn, void *data);
-5
tools/perf/util/pmu.c
··· 819 819 return file_available(path); 820 820 } 821 821 822 - __weak const struct pmu_metrics_table *pmu_metrics_table__find(void) 823 - { 824 - return perf_pmu__find_metrics_table(NULL); 825 - } 826 - 827 822 /** 828 823 * Return the length of the PMU name not including the suffix for uncore PMUs. 829 824 *
-1
tools/perf/util/pmu.h
··· 262 262 void pmu_add_cpu_aliases_table(struct perf_pmu *pmu, 263 263 const struct pmu_events_table *table); 264 264 265 - const struct pmu_metrics_table *pmu_metrics_table__find(void); 266 265 bool pmu_uncore_identifier_match(const char *compat, const char *id); 267 266 268 267 int perf_pmu__convert_scale(const char *scale, char **end, double *sval);