]> git.baikalelectronics.ru Git - kernel.git/commitdiff
perf evsel: Add arch_evsel__hw_name()
authorKan Liang <kan.liang@linux.intel.com>
Thu, 21 Jul 2022 06:57:03 +0000 (14:57 +0800)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 29 Jul 2022 16:41:19 +0000 (13:41 -0300)
The commit 330af8e7e3a692e3 ("perf: Extend PERF_TYPE_HARDWARE and
PERF_TYPE_HW_CACHE") extends the two types to become PMU aware types for
a hybrid system. However, current evsel__hw_name doesn't take the PMU
type into account. It mistakenly returns the "unknown-hardware" for the
hardware event with a specific PMU type.

Add an arch specific arch_evsel__hw_name() to specially handle the PMU
aware hardware event.

Currently, the extend PERF_TYPE_HARDWARE and PERF_TYPE_HW_CACHE is only
supported by X86. Only implement the specific arch_evsel__hw_name() for
X86 in the patch.

Nothing is changed for the other archs.

Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Acked-by: Ian Rogers <irogers@google.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20220721065706.2886112-3-zhengjun.xing@linux.intel.com
Signed-off-by: Xing Zhengjun <zhengjun.xing@linux.intel.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/arch/x86/util/evsel.c
tools/perf/util/evsel.c
tools/perf/util/evsel.h

index 882c1a8c1ded2492cd653cfb52dfc1051126cccb..ea3972d785d10b9eaa35a1329f16e8edd4192da5 100644 (file)
@@ -66,6 +66,26 @@ bool arch_evsel__must_be_in_group(const struct evsel *evsel)
                 strcasestr(evsel->name, "topdown"));
 }
 
+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);
+}
+
 static void ibs_l3miss_warn(void)
 {
        pr_warning(
index 14396ea5a968741c1e08e6812ab1c244a9ccabc2..4852089e1d79f205d2bba3ee6dbedb4c73304a5f 100644 (file)
@@ -594,9 +594,14 @@ static int evsel__add_modifiers(struct evsel *evsel, char *bf, size_t size)
        return r;
 }
 
+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));
+}
+
 static int evsel__hw_name(struct evsel *evsel, char *bf, size_t size)
 {
-       int r = scnprintf(bf, size, "%s", __evsel__hw_name(evsel->core.attr.config));
+       int r = arch_evsel__hw_name(evsel, bf, size);
        return r + evsel__add_modifiers(evsel, bf + r, size - r);
 }
 
index 699448f2bc2b4be1f773e4aa4b0d5aed04886d53..d927713b513e4a88c788f638f239bc6a0648c79d 100644 (file)
@@ -271,6 +271,7 @@ extern const char *const evsel__hw_names[PERF_COUNT_HW_MAX];
 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_cache_type_op_res_name(u8 type, u8 op, u8 result, char *bf, size_t size);
 const char *evsel__name(struct evsel *evsel);