perf: builtin-record: Provide advice if mmap'ing fails with EPERM.
authorNelson Elhage <nelhage@nelhage.com>
Mon, 19 Dec 2011 13:39:31 +0000 (08:39 -0500)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 23 Dec 2011 18:44:34 +0000 (16:44 -0200)
This failure is most likely due to running up against the
kernel.perf_event_mlock_kb sysctl, so we can tell the user what to do to
fix the issue.

Cc: Ingo Molnar <mingo@elte.hu>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1324301972-22740-3-git-send-email-nelhage@nelhage.com
Signed-off-by: Nelson Elhage <nelhage@nelhage.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-record.c

index f8fd14fb62ecb44a0a677e9ec0c27960bb2f077d..56bb4476e3ba09b24253321cde35deeb62f3c5c0 100644 (file)
@@ -272,8 +272,15 @@ try_again:
                exit(-1);
        }
 
-       if (perf_evlist__mmap(evlist, opts->mmap_pages, false) < 0)
+       if (perf_evlist__mmap(evlist, opts->mmap_pages, false) < 0) {
+               if (errno == EPERM)
+                       die("Permission error mapping pages.\n"
+                           "Consider increasing "
+                           "/proc/sys/kernel/perf_event_mlock_kb,\n"
+                           "or try again with a smaller value of -m/--mmap_pages.\n"
+                           "(current value: %d)\n", opts->mmap_pages);
                die("failed to mmap with %d (%s)\n", errno, strerror(errno));
+       }
 
        if (rec->file_new)
                session->evlist = evlist;