perf mem: Search event name with more flexible path
authorLeo Yan <leo.yan@linaro.org>
Fri, 6 Nov 2020 09:48:45 +0000 (17:48 +0800)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 11 Nov 2020 13:28:12 +0000 (10:28 -0300)
The perf tool searches a memory event name under the folder
'/sys/devices/cpu/events/', this leads to the limitation for the
selection of a memory profiling event which must be under this folder.

Thus it's impossible to use any other event as memory event which is not
under this specific folder, e.g. Arm SPE hardware event is not located
in '/sys/devices/cpu/events/' so it cannot be enabled for memory
profiling.

This patch changes to search folder from '/sys/devices/cpu/events/' to
'/sys/devices', so it give flexibility to find events which can be used
for memory profiling.

Signed-off-by: Leo Yan <leo.yan@linaro.org>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Link: https://lore.kernel.org/r/20201106094853.21082-2-leo.yan@linaro.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/mem-events.c

index ea0af0b..35c8d17 100644 (file)
@@ -18,8 +18,8 @@ unsigned int perf_mem_events__loads_ldlat = 30;
 #define E(t, n, s) { .tag = t, .name = n, .sysfs_name = s }
 
 struct perf_mem_event perf_mem_events[PERF_MEM_EVENTS__MAX] = {
-       E("ldlat-loads",        "cpu/mem-loads,ldlat=%u/P",     "mem-loads"),
-       E("ldlat-stores",       "cpu/mem-stores/P",             "mem-stores"),
+       E("ldlat-loads",        "cpu/mem-loads,ldlat=%u/P",     "cpu/events/mem-loads"),
+       E("ldlat-stores",       "cpu/mem-stores/P",             "cpu/events/mem-stores"),
 };
 #undef E
 
@@ -93,7 +93,7 @@ int perf_mem_events__init(void)
                struct perf_mem_event *e = &perf_mem_events[j];
                struct stat st;
 
-               scnprintf(path, PATH_MAX, "%s/devices/cpu/events/%s",
+               scnprintf(path, PATH_MAX, "%s/devices/%s",
                          mnt, e->sysfs_name);
 
                if (!stat(path, &st))