Skip to content

Commit 8f99786

Browse files
captain5050acmel
authored andcommitted
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>
1 parent 0434410 commit 8f99786

File tree

6 files changed

+9
-39
lines changed

6 files changed

+9
-39
lines changed

tools/perf/arch/arm64/util/pmu.c

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,9 @@
11
// SPDX-License-Identifier: GPL-2.0
22

3-
#include <internal/cpumap.h>
4-
#include "../../../util/cpumap.h"
5-
#include "../../../util/header.h"
63
#include "../../../util/pmu.h"
74
#include "../../../util/pmus.h"
85
#include "../../../util/tool_pmu.h"
96
#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-
}
277

288
u64 tool_pmu__cpu_slots_per_cycle(void)
299
{

tools/perf/pmu-events/empty-pmu-events.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -587,14 +587,12 @@ const struct pmu_events_table *perf_pmu__find_events_table(struct perf_pmu *pmu)
587587
return NULL;
588588
}
589589

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)
591591
{
592-
const struct pmu_events_map *map = map_for_pmu(pmu);
593-
594-
if (!map)
595-
return NULL;
592+
struct perf_cpu cpu = {-1};
593+
const struct pmu_events_map *map = map_for_cpu(cpu);
596594

597-
return &map->metric_table;
595+
return map ? &map->metric_table : NULL;
598596
}
599597

600598
const struct pmu_events_table *find_core_events_table(const char *arch, const char *cpuid)

tools/perf/pmu-events/jevents.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,14 +1103,12 @@ def print_system_mapping_table() -> None:
11031103
return NULL;
11041104
}
11051105
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)
11071107
{
1108-
const struct pmu_events_map *map = map_for_pmu(pmu);
1109-
1110-
if (!map)
1111-
return NULL;
1108+
struct perf_cpu cpu = {-1};
1109+
const struct pmu_events_map *map = map_for_cpu(cpu);
11121110
1113-
return &map->metric_table;
1111+
return map ? &map->metric_table : NULL;
11141112
}
11151113
11161114
const struct pmu_events_table *find_core_events_table(const char *arch, const char *cpuid)

tools/perf/pmu-events/pmu-events.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ int pmu_metrics_table__for_each_metric(const struct pmu_metrics_table *table, pm
103103
void *data);
104104

105105
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);
107107
const struct pmu_events_table *find_core_events_table(const char *arch, const char *cpuid);
108108
const struct pmu_metrics_table *find_core_metrics_table(const char *arch, const char *cpuid);
109109
int pmu_for_each_core_event(pmu_event_iter_fn fn, void *data);

tools/perf/util/pmu.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -819,11 +819,6 @@ static int is_sysfs_pmu_core(const char *name)
819819
return file_available(path);
820820
}
821821

822-
__weak const struct pmu_metrics_table *pmu_metrics_table__find(void)
823-
{
824-
return perf_pmu__find_metrics_table(NULL);
825-
}
826-
827822
/**
828823
* Return the length of the PMU name not including the suffix for uncore PMUs.
829824
*

tools/perf/util/pmu.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,6 @@ void perf_pmu__arch_init(struct perf_pmu *pmu);
262262
void pmu_add_cpu_aliases_table(struct perf_pmu *pmu,
263263
const struct pmu_events_table *table);
264264

265-
const struct pmu_metrics_table *pmu_metrics_table__find(void);
266265
bool pmu_uncore_identifier_match(const char *compat, const char *id);
267266

268267
int perf_pmu__convert_scale(const char *scale, char **end, double *sval);

0 commit comments

Comments
 (0)