Commit 8f997865 authored by Ian Rogers's avatar Ian Rogers Committed by Arnaldo Carvalho de Melo
Browse files

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: default avatarJames Clark <james.clark@linaro.org>
Signed-off-by: default avatarIan Rogers <irogers@google.com>
Tested-by: default avatarXu 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 0434410f
Loading
Loading
Loading
Loading
+0 −20
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0

#include <internal/cpumap.h>
#include "../../../util/cpumap.h"
#include "../../../util/header.h"
#include "../../../util/pmu.h"
#include "../../../util/pmus.h"
#include "../../../util/tool_pmu.h"
#include <api/fs/fs.h>
#include <math.h>

const struct pmu_metrics_table *pmu_metrics_table__find(void)
{
	struct perf_pmu *pmu;

	/* Metrics aren't currently supported on heterogeneous Arm systems */
	if (perf_pmus__num_core_pmus() > 1)
		return NULL;

	/* Doesn't matter which one here because they'll all be the same */
	pmu = perf_pmus__find_core_pmu();
	if (pmu)
		return perf_pmu__find_metrics_table(pmu);

	return NULL;
}

u64 tool_pmu__cpu_slots_per_cycle(void)
{
+4 −6
Original line number Diff line number Diff line
@@ -587,14 +587,12 @@ const struct pmu_events_table *perf_pmu__find_events_table(struct perf_pmu *pmu)
        return NULL;
}

const struct pmu_metrics_table *perf_pmu__find_metrics_table(struct perf_pmu *pmu)
const struct pmu_metrics_table *pmu_metrics_table__find(void)
{
        const struct pmu_events_map *map = map_for_pmu(pmu);

        if (!map)
                return NULL;
        struct perf_cpu cpu = {-1};
        const struct pmu_events_map *map = map_for_cpu(cpu);

	return &map->metric_table;
        return map ? &map->metric_table : NULL;
}

const struct pmu_events_table *find_core_events_table(const char *arch, const char *cpuid)
+4 −6
Original line number Diff line number Diff line
@@ -1103,14 +1103,12 @@ const struct pmu_events_table *perf_pmu__find_events_table(struct perf_pmu *pmu)
        return NULL;
}

const struct pmu_metrics_table *perf_pmu__find_metrics_table(struct perf_pmu *pmu)
const struct pmu_metrics_table *pmu_metrics_table__find(void)
{
        const struct pmu_events_map *map = map_for_pmu(pmu);

        if (!map)
                return NULL;
        struct perf_cpu cpu = {-1};
        const struct pmu_events_map *map = map_for_cpu(cpu);

	return &map->metric_table;
        return map ? &map->metric_table : NULL;
}

const struct pmu_events_table *find_core_events_table(const char *arch, const char *cpuid)
+1 −1
Original line number Diff line number Diff line
@@ -103,7 +103,7 @@ int pmu_metrics_table__for_each_metric(const struct pmu_metrics_table *table, pm
				     void *data);

const struct pmu_events_table *perf_pmu__find_events_table(struct perf_pmu *pmu);
const struct pmu_metrics_table *perf_pmu__find_metrics_table(struct perf_pmu *pmu);
const struct pmu_metrics_table *pmu_metrics_table__find(void);
const struct pmu_events_table *find_core_events_table(const char *arch, const char *cpuid);
const struct pmu_metrics_table *find_core_metrics_table(const char *arch, const char *cpuid);
int pmu_for_each_core_event(pmu_event_iter_fn fn, void *data);
+0 −5
Original line number Diff line number Diff line
@@ -819,11 +819,6 @@ static int is_sysfs_pmu_core(const char *name)
	return file_available(path);
}

__weak const struct pmu_metrics_table *pmu_metrics_table__find(void)
{
	return perf_pmu__find_metrics_table(NULL);
}

/**
 * Return the length of the PMU name not including the suffix for uncore PMUs.
 *
Loading