diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/util/evlist.c | 17 |
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, int perf_evlist__strerror_mmap(struct perf_evlist *evlist, int err, char *buf, size_t size) { char sbuf[STRERR_BUFSIZE], *emsg = strerror_r(err, sbuf, sizeof(sbuf)); - int pages_attempted = evlist->mmap_len / 1024, pages_max_per_user; + int pages_attempted = evlist->mmap_len / 1024, pages_max_per_user, printed = 0; switch (err) { case EPERM: sysctl__read_int("kernel/perf_event_mlock_kb", &pages_max_per_user); - scnprintf(buf, size, "Error:\t%s.\n" + printed += scnprintf(buf + printed, size - printed, + "Error:\t%s.\n" "Hint:\tCheck /proc/sys/kernel/perf_event_mlock_kb (%d kB) setting.\n" - "Hint:\tTried using %zd kB.\n" - "Hint:\tTry using a smaller -m/--mmap-pages value.", + "Hint:\tTried using %zd kB.\n", emsg, pages_max_per_user, pages_attempted); + + if (pages_attempted >= pages_max_per_user) { + printed += scnprintf(buf + printed, size - printed, + "Hint:\tTry 'sudo sh -c \"echo %d > /proc/sys/kernel/perf_event_mlock_kb\"', or\n", + pages_max_per_user + pages_attempted); + } + + printed += scnprintf(buf + printed, size - printed, + "Hint:\tTry using a smaller -m/--mmap-pages value."); break; default: scnprintf(buf, size, "%s", emsg); |