From 54fbad54ebcde9db9c7459e9e379f2350c25e1f1 Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Wed, 24 Feb 2016 09:46:42 +0100 Subject: 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 Tested-by: Arnaldo Carvalho de Melo Cc: Andi Kleen Cc: David Ahern Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/1456303616-26926-2-git-send-email-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-mem.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'tools/perf/builtin-mem.c') diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c index b3f8a89ede40..f1fa7b8d1f69 100644 --- a/tools/perf/builtin-mem.c +++ b/tools/perf/builtin-mem.c @@ -40,10 +40,11 @@ static int parse_record_events(const struct option *opt, for (j = 0; j < PERF_MEM_EVENTS__MAX; j++) { struct perf_mem_event *e = &perf_mem_events[j]; - fprintf(stderr, "%-20s%s", - e->tag, verbose ? "" : "\n"); - if (verbose) - fprintf(stderr, " [%s]\n", e->name); + fprintf(stderr, "%-13s%-*s%s\n", + e->tag, + verbose ? 25 : 0, + verbose ? e->name : "", + e->supported ? ": available" : ""); } exit(0); } @@ -92,6 +93,12 @@ static int __cmd_record(int argc, const char **argv, struct perf_mem *mem) if (!perf_mem_events[j].record) continue; + if (!perf_mem_events[j].supported) { + pr_err("failed: event '%s' not supported\n", + perf_mem_events[j].name); + return -1; + } + rec_argv[i++] = "-e"; rec_argv[i++] = perf_mem_events[j].name; }; @@ -355,6 +362,11 @@ int cmd_mem(int argc, const char **argv, const char *prefix __maybe_unused) NULL }; + if (perf_mem_events__init()) { + pr_err("failed: memory events not supported\n"); + return -1; + } + argc = parse_options_subcommand(argc, argv, mem_options, mem_subcommands, mem_usage, PARSE_OPT_STOP_AT_NON_OPTION); -- cgit v1.2.3