diff options
author | Jiri Olsa <jolsa@kernel.org> | 2016-02-24 09:46:42 +0100 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-02-24 10:10:59 -0300 |
commit | 54fbad54ebcde9db9c7459e9e379f2350c25e1f1 (patch) | |
tree | dc1ea35ca55cd0dfd2220aa0e061cc5ee1731304 /tools/perf/util/mem-events.c | |
parent | c2b8d8c55c0235e21c563283f634bcfd2ba7bc1e (diff) | |
download | talos-obmc-linux-54fbad54ebcde9db9c7459e9e379f2350c25e1f1.tar.gz talos-obmc-linux-54fbad54ebcde9db9c7459e9e379f2350c25e1f1.zip |
perf mem record: Check for memory events support
Check if current kernel support available memory events and display the
status within -e list option:
$ perf mem record -e list
ldlat-loads : available
ldlat-stores : available
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1456303616-26926-2-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/mem-events.c')
-rw-r--r-- | tools/perf/util/mem-events.c | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/tools/perf/util/mem-events.c b/tools/perf/util/mem-events.c index b1507c04b257..e21853fe1312 100644 --- a/tools/perf/util/mem-events.c +++ b/tools/perf/util/mem-events.c @@ -2,15 +2,20 @@ #include <stdlib.h> #include <string.h> #include <errno.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> +#include <api/fs/fs.h> #include "mem-events.h" #include "debug.h" -#define E(t, n) { .tag = t, .name = n } +#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=30/P"), - E("ldlat-stores", "cpu/mem-stores/P"), + E("ldlat-loads", "cpu/mem-loads,ldlat=30/P", "mem-loads"), + E("ldlat-stores", "cpu/mem-stores/P", "mem-stores"), }; +#undef E #undef E @@ -49,3 +54,27 @@ int perf_mem_events__parse(const char *str) pr_err("failed: event '%s' not found, use '-e list' to get list of available events\n", str); return -1; } + +int perf_mem_events__init(void) +{ + const char *mnt = sysfs__mount(); + bool found = false; + int j; + + if (!mnt) + return -ENOENT; + + for (j = 0; j < PERF_MEM_EVENTS__MAX; j++) { + char path[PATH_MAX]; + struct perf_mem_event *e = &perf_mem_events[j]; + struct stat st; + + scnprintf(path, PATH_MAX, "%s/devices/cpu/events/%s", + mnt, e->sysfs_name); + + if (!stat(path, &st)) + e->supported = found = true; + } + + return found ? 0 : -ENOENT; +} |