aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2014-12-12 14:25:33 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2014-12-16 11:38:26 -0500
commite965bea1ad1a8062b306f7fcc5c3e05dc5213b7c (patch)
treed22afdd1269531177ce19cea4250ca3506541127 /tools
parente5d4a290da5366c397653c47c3e869a67b1bfa07 (diff)
perf evlist: Improve the strerror_mmap method
Considering the per user locked pages limit, improve the message when a user uses multiple simultaneous perf mmap calls: When the request is more than the current maximum: [acme@ssdandy linux]$ trace -m 128 usleep 1 Error: Operation not permitted. Hint: Check /proc/sys/kernel/perf_event_mlock_kb (516 kB) setting. Hint: Tried using 516 kB. Hint: Try 'sudo sh -c "echo 1032 > /proc/sys/kernel/perf_event_mlock_kb"', or Hint: Try using a smaller -m/--mmap-pages value. [acme@ssdandy linux]$ And when the limit is less than that: [acme@ssdandy linux]$ trace -m 512 usleep 1 Error: Operation not permitted. Hint: Check /proc/sys/kernel/perf_event_mlock_kb (2056 kB) setting. Hint: Tried using 2052 kB. Hint: Try using a smaller -m/--mmap-pages value. [acme@ssdandy linux]$ Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Borislav Petkov <bp@suse.de> Cc: David Ahern <dsahern@gmail.com> Cc: Don Zickus <dzickus@redhat.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-yqdie3c8qvdgenwleri267d4@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/util/evlist.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index d661f252b891..7847f3885081 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -1487,16 +1487,25 @@ int perf_evlist__strerror_open(struct perf_evlist *evlist __maybe_unused,
1487int perf_evlist__strerror_mmap(struct perf_evlist *evlist, int err, char *buf, size_t size) 1487int perf_evlist__strerror_mmap(struct perf_evlist *evlist, int err, char *buf, size_t size)
1488{ 1488{
1489 char sbuf[STRERR_BUFSIZE], *emsg = strerror_r(err, sbuf, sizeof(sbuf)); 1489 char sbuf[STRERR_BUFSIZE], *emsg = strerror_r(err, sbuf, sizeof(sbuf));
1490 int pages_attempted = evlist->mmap_len / 1024, pages_max_per_user; 1490 int pages_attempted = evlist->mmap_len / 1024, pages_max_per_user, printed = 0;
1491 1491
1492 switch (err) { 1492 switch (err) {
1493 case EPERM: 1493 case EPERM:
1494 sysctl__read_int("kernel/perf_event_mlock_kb", &pages_max_per_user); 1494 sysctl__read_int("kernel/perf_event_mlock_kb", &pages_max_per_user);
1495 scnprintf(buf, size, "Error:\t%s.\n" 1495 printed += scnprintf(buf + printed, size - printed,
1496 "Error:\t%s.\n"
1496 "Hint:\tCheck /proc/sys/kernel/perf_event_mlock_kb (%d kB) setting.\n" 1497 "Hint:\tCheck /proc/sys/kernel/perf_event_mlock_kb (%d kB) setting.\n"
1497 "Hint:\tTried using %zd kB.\n" 1498 "Hint:\tTried using %zd kB.\n",
1498 "Hint:\tTry using a smaller -m/--mmap-pages value.",
1499 emsg, pages_max_per_user, pages_attempted); 1499 emsg, pages_max_per_user, pages_attempted);
1500
1501 if (pages_attempted >= pages_max_per_user) {
1502 printed += scnprintf(buf + printed, size - printed,
1503 "Hint:\tTry 'sudo sh -c \"echo %d > /proc/sys/kernel/perf_event_mlock_kb\"', or\n",
1504 pages_max_per_user + pages_attempted);
1505 }
1506
1507 printed += scnprintf(buf + printed, size - printed,
1508 "Hint:\tTry using a smaller -m/--mmap-pages value.");
1500 break; 1509 break;
1501 default: 1510 default:
1502 scnprintf(buf, size, "%s", emsg); 1511 scnprintf(buf, size, "%s", emsg);