perf mem: Support ARM SPE events
authorLeo Yan <leo.yan@linaro.org>
Fri, 6 Nov 2020 09:48:53 +0000 (17:48 +0800)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 11 Nov 2020 15:27:37 +0000 (12:27 -0300)
This patch adds ARM SPE events for perf memory profiling:

  'spe-load': event for only recording memory load ops;
  'spe-store': event for only recording memory store ops;
  'spe-ldst': event for recording memory load and store ops.

Signed-off-by: Leo Yan <leo.yan@linaro.org>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Link: https://lore.kernel.org/r/20201106094853.21082-10-leo.yan@linaro.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/arch/arm64/util/Build
tools/perf/arch/arm64/util/mem-events.c [new file with mode: 0644]

index 8d2b9bcfffcaf578653ddafd5e7538209a50abff..ead2f2275eee709cd8c522d2672c684ed00f0835 100644 (file)
@@ -10,4 +10,4 @@ perf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o
 perf-$(CONFIG_AUXTRACE) += ../../arm/util/pmu.o \
                              ../../arm/util/auxtrace.o \
                              ../../arm/util/cs-etm.o \
-                             arm-spe.o
+                             arm-spe.o mem-events.o
diff --git a/tools/perf/arch/arm64/util/mem-events.c b/tools/perf/arch/arm64/util/mem-events.c
new file mode 100644 (file)
index 0000000..2a24973
--- /dev/null
@@ -0,0 +1,37 @@
+// SPDX-License-Identifier: GPL-2.0
+#include "map_symbol.h"
+#include "mem-events.h"
+
+#define E(t, n, s) { .tag = t, .name = n, .sysfs_name = s }
+
+static struct perf_mem_event perf_mem_events[PERF_MEM_EVENTS__MAX] = {
+       E("spe-load",   "arm_spe_0/ts_enable=1,load_filter=1,store_filter=0,min_latency=%u/",   "arm_spe_0"),
+       E("spe-store",  "arm_spe_0/ts_enable=1,load_filter=0,store_filter=1/",                  "arm_spe_0"),
+       E("spe-ldst",   "arm_spe_0/ts_enable=1,load_filter=1,store_filter=1,min_latency=%u/",   "arm_spe_0"),
+};
+
+static char mem_ev_name[100];
+
+struct perf_mem_event *perf_mem_events__ptr(int i)
+{
+       if (i >= PERF_MEM_EVENTS__MAX)
+               return NULL;
+
+       return &perf_mem_events[i];
+}
+
+char *perf_mem_events__name(int i)
+{
+       struct perf_mem_event *e = perf_mem_events__ptr(i);
+
+       if (i >= PERF_MEM_EVENTS__MAX)
+               return NULL;
+
+       if (i == PERF_MEM_EVENTS__LOAD || i == PERF_MEM_EVENTS__LOAD_STORE)
+               scnprintf(mem_ev_name, sizeof(mem_ev_name),
+                         e->name, perf_mem_events__loads_ldlat);
+       else /* PERF_MEM_EVENTS__STORE */
+               scnprintf(mem_ev_name, sizeof(mem_ev_name), e->name);
+
+       return mem_ev_name;
+}