aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-lock.c
diff options
context:
space:
mode:
authorDavid Ahern <dsahern@gmail.com>2012-08-09 12:35:37 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-08-09 13:14:28 -0400
commitd25dcba8541c1cc31621d5cefce0304dafb9ae4f (patch)
tree9184715b6ee64f27c797a21ee01e9ede9f831e59 /tools/perf/builtin-lock.c
parent87b6a3ad40ba304ec468b972e979e7e410852476 (diff)
perf lock record: improve message when tracepoints are not enabled
If CONFIG options required for perf-lock are not enabled then the corresponding tracepoints will not be enabled. Currently, the message to the user is: $ perf lock record -a -- sleep 1 invalid or unsupported event: 'lock:lock_acquire' Run 'perf list' for a list of valid events Improve the message with a suggestion on which CONFIG options are needed: $ perf lock record -a -- sleep 1 tracepoint lock:lock_acquire is not enabled. Are CONFIG_LOCKDEP and CONFIG_LOCK_STAT enabled? Suggested-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net> Signed-off-by: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/1344530137-25521-1-git-send-email-dsahern@gmail.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-lock.c')
-rw-r--r--tools/perf/builtin-lock.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c
index 3f8b9550a6ef..585aae2858b8 100644
--- a/tools/perf/builtin-lock.c
+++ b/tools/perf/builtin-lock.c
@@ -903,16 +903,19 @@ static const struct option lock_options[] = {
903 OPT_END() 903 OPT_END()
904}; 904};
905 905
906static const char * const lock_tracepoints[] = {
907 "lock:lock_acquire", /* CONFIG_LOCKDEP */
908 "lock:lock_acquired", /* CONFIG_LOCKDEP, CONFIG_LOCK_STAT */
909 "lock:lock_contended", /* CONFIG_LOCKDEP, CONFIG_LOCK_STAT */
910 "lock:lock_release", /* CONFIG_LOCKDEP */
911};
912
906static const char *record_args[] = { 913static const char *record_args[] = {
907 "record", 914 "record",
908 "-R", 915 "-R",
909 "-f", 916 "-f",
910 "-m", "1024", 917 "-m", "1024",
911 "-c", "1", 918 "-c", "1",
912 "-e", "lock:lock_acquire",
913 "-e", "lock:lock_acquired",
914 "-e", "lock:lock_contended",
915 "-e", "lock:lock_release",
916}; 919};
917 920
918static int __cmd_record(int argc, const char **argv) 921static int __cmd_record(int argc, const char **argv)
@@ -920,15 +923,31 @@ static int __cmd_record(int argc, const char **argv)
920 unsigned int rec_argc, i, j; 923 unsigned int rec_argc, i, j;
921 const char **rec_argv; 924 const char **rec_argv;
922 925
926 for (i = 0; i < ARRAY_SIZE(lock_tracepoints); i++) {
927 if (!is_valid_tracepoint(lock_tracepoints[i])) {
928 pr_err("tracepoint %s is not enabled. "
929 "Are CONFIG_LOCKDEP and CONFIG_LOCK_STAT enabled?\n",
930 lock_tracepoints[i]);
931 return 1;
932 }
933 }
934
923 rec_argc = ARRAY_SIZE(record_args) + argc - 1; 935 rec_argc = ARRAY_SIZE(record_args) + argc - 1;
924 rec_argv = calloc(rec_argc + 1, sizeof(char *)); 936 /* factor of 2 is for -e in front of each tracepoint */
937 rec_argc += 2 * ARRAY_SIZE(lock_tracepoints);
925 938
939 rec_argv = calloc(rec_argc + 1, sizeof(char *));
926 if (rec_argv == NULL) 940 if (rec_argv == NULL)
927 return -ENOMEM; 941 return -ENOMEM;
928 942
929 for (i = 0; i < ARRAY_SIZE(record_args); i++) 943 for (i = 0; i < ARRAY_SIZE(record_args); i++)
930 rec_argv[i] = strdup(record_args[i]); 944 rec_argv[i] = strdup(record_args[i]);
931 945
946 for (j = 0; j < ARRAY_SIZE(lock_tracepoints); j++) {
947 rec_argv[i++] = "-e";
948 rec_argv[i++] = strdup(lock_tracepoints[j]);
949 }
950
932 for (j = 1; j < (unsigned int)argc; j++, i++) 951 for (j = 1; j < (unsigned int)argc; j++, i++)
933 rec_argv[i] = argv[j]; 952 rec_argv[i] = argv[j];
934 953