mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-12-29 17:25:38 +00:00
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>
This commit is contained in:
parent
494c403ff1
commit
0434410fa4
@ -503,11 +503,11 @@ int pmu_metrics_table__for_each_metric(const struct pmu_metrics_table *table,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct pmu_events_map *map_for_pmu(struct perf_pmu *pmu)
|
||||
static const struct pmu_events_map *map_for_cpu(struct perf_cpu cpu)
|
||||
{
|
||||
static struct {
|
||||
const struct pmu_events_map *map;
|
||||
struct perf_pmu *pmu;
|
||||
struct perf_cpu cpu;
|
||||
} last_result;
|
||||
static struct {
|
||||
const struct pmu_events_map *map;
|
||||
@ -515,15 +515,12 @@ static const struct pmu_events_map *map_for_pmu(struct perf_pmu *pmu)
|
||||
} last_map_search;
|
||||
static bool has_last_result, has_last_map_search;
|
||||
const struct pmu_events_map *map = NULL;
|
||||
struct perf_cpu cpu = {-1};
|
||||
char *cpuid = NULL;
|
||||
size_t i;
|
||||
|
||||
if (has_last_result && last_result.pmu == pmu)
|
||||
if (has_last_result && last_result.cpu.cpu == cpu.cpu)
|
||||
return last_result.map;
|
||||
|
||||
if (pmu)
|
||||
cpu = perf_cpu_map__min(pmu->cpus);
|
||||
cpuid = get_cpuid_allow_env_override(cpu);
|
||||
|
||||
/*
|
||||
@ -555,12 +552,21 @@ static const struct pmu_events_map *map_for_pmu(struct perf_pmu *pmu)
|
||||
has_last_map_search = true;
|
||||
}
|
||||
out_update_last_result:
|
||||
last_result.pmu = pmu;
|
||||
last_result.cpu = cpu;
|
||||
last_result.map = map;
|
||||
has_last_result = true;
|
||||
return map;
|
||||
}
|
||||
|
||||
static const struct pmu_events_map *map_for_pmu(struct perf_pmu *pmu)
|
||||
{
|
||||
struct perf_cpu cpu = {-1};
|
||||
|
||||
if (pmu)
|
||||
cpu = perf_cpu_map__min(pmu->cpus);
|
||||
return map_for_cpu(cpu);
|
||||
}
|
||||
|
||||
const struct pmu_events_table *perf_pmu__find_events_table(struct perf_pmu *pmu)
|
||||
{
|
||||
const struct pmu_events_map *map = map_for_pmu(pmu);
|
||||
|
@ -1019,11 +1019,11 @@ int pmu_metrics_table__for_each_metric(const struct pmu_metrics_table *table,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct pmu_events_map *map_for_pmu(struct perf_pmu *pmu)
|
||||
static const struct pmu_events_map *map_for_cpu(struct perf_cpu cpu)
|
||||
{
|
||||
static struct {
|
||||
const struct pmu_events_map *map;
|
||||
struct perf_pmu *pmu;
|
||||
struct perf_cpu cpu;
|
||||
} last_result;
|
||||
static struct {
|
||||
const struct pmu_events_map *map;
|
||||
@ -1031,15 +1031,12 @@ static const struct pmu_events_map *map_for_pmu(struct perf_pmu *pmu)
|
||||
} last_map_search;
|
||||
static bool has_last_result, has_last_map_search;
|
||||
const struct pmu_events_map *map = NULL;
|
||||
struct perf_cpu cpu = {-1};
|
||||
char *cpuid = NULL;
|
||||
size_t i;
|
||||
|
||||
if (has_last_result && last_result.pmu == pmu)
|
||||
if (has_last_result && last_result.cpu.cpu == cpu.cpu)
|
||||
return last_result.map;
|
||||
|
||||
if (pmu)
|
||||
cpu = perf_cpu_map__min(pmu->cpus);
|
||||
cpuid = get_cpuid_allow_env_override(cpu);
|
||||
|
||||
/*
|
||||
@ -1071,12 +1068,21 @@ static const struct pmu_events_map *map_for_pmu(struct perf_pmu *pmu)
|
||||
has_last_map_search = true;
|
||||
}
|
||||
out_update_last_result:
|
||||
last_result.pmu = pmu;
|
||||
last_result.cpu = cpu;
|
||||
last_result.map = map;
|
||||
has_last_result = true;
|
||||
return map;
|
||||
}
|
||||
|
||||
static const struct pmu_events_map *map_for_pmu(struct perf_pmu *pmu)
|
||||
{
|
||||
struct perf_cpu cpu = {-1};
|
||||
|
||||
if (pmu)
|
||||
cpu = perf_cpu_map__min(pmu->cpus);
|
||||
return map_for_cpu(cpu);
|
||||
}
|
||||
|
||||
const struct pmu_events_table *perf_pmu__find_events_table(struct perf_pmu *pmu)
|
||||
{
|
||||
const struct pmu_events_map *map = map_for_pmu(pmu);
|
||||
|
Loading…
Reference in New Issue
Block a user