Skip to content

Commit 0434410

Browse files
captain5050acmel
authored andcommitted
perf jevents: Add map_for_cpu()
The PMU is no longer part of the map finding process and for metrics doesn't make sense as they lack a PMU. 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-8-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 494c403 commit 0434410

File tree

2 files changed

+26
-14
lines changed

2 files changed

+26
-14
lines changed

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

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -503,27 +503,24 @@ int pmu_metrics_table__for_each_metric(const struct pmu_metrics_table *table,
503503
return 0;
504504
}
505505

506-
static const struct pmu_events_map *map_for_pmu(struct perf_pmu *pmu)
506+
static const struct pmu_events_map *map_for_cpu(struct perf_cpu cpu)
507507
{
508508
static struct {
509509
const struct pmu_events_map *map;
510-
struct perf_pmu *pmu;
510+
struct perf_cpu cpu;
511511
} last_result;
512512
static struct {
513513
const struct pmu_events_map *map;
514514
char *cpuid;
515515
} last_map_search;
516516
static bool has_last_result, has_last_map_search;
517517
const struct pmu_events_map *map = NULL;
518-
struct perf_cpu cpu = {-1};
519518
char *cpuid = NULL;
520519
size_t i;
521520

522-
if (has_last_result && last_result.pmu == pmu)
521+
if (has_last_result && last_result.cpu.cpu == cpu.cpu)
523522
return last_result.map;
524523

525-
if (pmu)
526-
cpu = perf_cpu_map__min(pmu->cpus);
527524
cpuid = get_cpuid_allow_env_override(cpu);
528525

529526
/*
@@ -555,12 +552,21 @@ static const struct pmu_events_map *map_for_pmu(struct perf_pmu *pmu)
555552
has_last_map_search = true;
556553
}
557554
out_update_last_result:
558-
last_result.pmu = pmu;
555+
last_result.cpu = cpu;
559556
last_result.map = map;
560557
has_last_result = true;
561558
return map;
562559
}
563560

561+
static const struct pmu_events_map *map_for_pmu(struct perf_pmu *pmu)
562+
{
563+
struct perf_cpu cpu = {-1};
564+
565+
if (pmu)
566+
cpu = perf_cpu_map__min(pmu->cpus);
567+
return map_for_cpu(cpu);
568+
}
569+
564570
const struct pmu_events_table *perf_pmu__find_events_table(struct perf_pmu *pmu)
565571
{
566572
const struct pmu_events_map *map = map_for_pmu(pmu);

tools/perf/pmu-events/jevents.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,27 +1019,24 @@ def print_system_mapping_table() -> None:
10191019
return 0;
10201020
}
10211021
1022-
static const struct pmu_events_map *map_for_pmu(struct perf_pmu *pmu)
1022+
static const struct pmu_events_map *map_for_cpu(struct perf_cpu cpu)
10231023
{
10241024
static struct {
10251025
const struct pmu_events_map *map;
1026-
struct perf_pmu *pmu;
1026+
struct perf_cpu cpu;
10271027
} last_result;
10281028
static struct {
10291029
const struct pmu_events_map *map;
10301030
char *cpuid;
10311031
} last_map_search;
10321032
static bool has_last_result, has_last_map_search;
10331033
const struct pmu_events_map *map = NULL;
1034-
struct perf_cpu cpu = {-1};
10351034
char *cpuid = NULL;
10361035
size_t i;
10371036
1038-
if (has_last_result && last_result.pmu == pmu)
1037+
if (has_last_result && last_result.cpu.cpu == cpu.cpu)
10391038
return last_result.map;
10401039
1041-
if (pmu)
1042-
cpu = perf_cpu_map__min(pmu->cpus);
10431040
cpuid = get_cpuid_allow_env_override(cpu);
10441041
10451042
/*
@@ -1071,12 +1068,21 @@ def print_system_mapping_table() -> None:
10711068
has_last_map_search = true;
10721069
}
10731070
out_update_last_result:
1074-
last_result.pmu = pmu;
1071+
last_result.cpu = cpu;
10751072
last_result.map = map;
10761073
has_last_result = true;
10771074
return map;
10781075
}
10791076
1077+
static const struct pmu_events_map *map_for_pmu(struct perf_pmu *pmu)
1078+
{
1079+
struct perf_cpu cpu = {-1};
1080+
1081+
if (pmu)
1082+
cpu = perf_cpu_map__min(pmu->cpus);
1083+
return map_for_cpu(cpu);
1084+
}
1085+
10801086
const struct pmu_events_table *perf_pmu__find_events_table(struct perf_pmu *pmu)
10811087
{
10821088
const struct pmu_events_map *map = map_for_pmu(pmu);

0 commit comments

Comments
 (0)