@@ -1,3 +1,4 @@
+perf-util-y += evsel.o
perf-util-y += header.o
perf-util-y += machine.o
perf-util-y += perf_regs.o
new file mode 100644
@@ -0,0 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
+#include "util/evsel.h"
+
+int arch_evsel__hw_name(struct evsel *evsel, char *bf, size_t size)
+{
+ return evsel__hw_name_ext_type_id(evsel, bf, size);
+}
@@ -49,22 +49,7 @@ bool arch_evsel__must_be_in_group(const struct evsel *evsel)
int arch_evsel__hw_name(struct evsel *evsel, char *bf, size_t size)
{
- u64 event = evsel->core.attr.config & PERF_HW_EVENT_MASK;
- u64 pmu = evsel->core.attr.config >> PERF_PMU_TYPE_SHIFT;
- const char *event_name;
-
- if (event < PERF_COUNT_HW_MAX && evsel__hw_names[event])
- event_name = evsel__hw_names[event];
- else
- event_name = "unknown-hardware";
-
- /* The PMU type is not required for the non-hybrid platform. */
- if (!pmu)
- return scnprintf(bf, size, "%s", event_name);
-
- return scnprintf(bf, size, "%s/%s/",
- evsel->pmu_name ? evsel->pmu_name : "cpu",
- event_name);
+ return evsel__hw_name_ext_type_id(evsel, bf, size);
}
static void ibs_l3miss_warn(void)
@@ -584,6 +584,30 @@ int __weak arch_evsel__hw_name(struct evsel *evsel, char *bf, size_t size)
return scnprintf(bf, size, "%s", __evsel__hw_name(evsel->core.attr.config));
}
+/*
+ * Version of evsel__hw_name() used on platforms where perf_pmus__supports_extended_type()
+ * may be true and the type needs to be extracted and masked.
+ */
+int evsel__hw_name_ext_type_id(struct evsel *evsel, char *bf, size_t size)
+{
+ u64 event = evsel->core.attr.config & PERF_HW_EVENT_MASK;
+ u64 pmu = evsel->core.attr.config >> PERF_PMU_TYPE_SHIFT;
+ const char *event_name;
+
+ if (event < PERF_COUNT_HW_MAX && evsel__hw_names[event])
+ event_name = evsel__hw_names[event];
+ else
+ event_name = "unknown-hardware";
+
+ /* The PMU type is not required for the non-hybrid platform. */
+ if (!pmu)
+ return scnprintf(bf, size, "%s", event_name);
+
+ return scnprintf(bf, size, "%s/%s/",
+ evsel->pmu_name ? evsel->pmu_name : "cpu",
+ event_name);
+}
+
static int evsel__hw_name(struct evsel *evsel, char *bf, size_t size)
{
int r = arch_evsel__hw_name(evsel, bf, size);
@@ -299,7 +299,7 @@ extern const char *const evsel__sw_names[PERF_COUNT_SW_MAX];
extern char *evsel__bpf_counter_events;
bool evsel__match_bpf_counter_events(const char *name);
int arch_evsel__hw_name(struct evsel *evsel, char *bf, size_t size);
-
+int evsel__hw_name_ext_type_id(struct evsel *evsel, char *bf, size_t size);
int __evsel__hw_cache_type_op_res_name(u8 type, u8 op, u8 result, char *bf, size_t size);
const char *evsel__name(struct evsel *evsel);
bool evsel__name_is(struct evsel *evsel, const char *name);
Both of these platforms share the same extended type ID mechanism, so share the implementation of the evsel name lookup. Signed-off-by: James Clark <james.clark@linaro.org> --- tools/perf/arch/arm64/util/Build | 1 + tools/perf/arch/arm64/util/evsel.c | 7 +++++++ tools/perf/arch/x86/util/evsel.c | 17 +---------------- tools/perf/util/evsel.c | 24 ++++++++++++++++++++++++ tools/perf/util/evsel.h | 2 +- 5 files changed, 34 insertions(+), 17 deletions(-) create mode 100644 tools/perf/arch/arm64/util/evsel.c