Commit-ID:  e965bea1ad1a8062b306f7fcc5c3e05dc5213b7c
Gitweb:     http://git.kernel.org/tip/e965bea1ad1a8062b306f7fcc5c3e05dc5213b7c
Author:     Arnaldo Carvalho de Melo <a...@redhat.com>
AuthorDate: Fri, 12 Dec 2014 16:25:33 -0300
Committer:  Arnaldo Carvalho de Melo <a...@redhat.com>
CommitDate: Tue, 16 Dec 2014 13:38:26 -0300

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.hun...@intel.com>
Cc: Borislav Petkov <b...@suse.de>
Cc: David Ahern <dsah...@gmail.com>
Cc: Don Zickus <dzic...@redhat.com>
Cc: Frederic Weisbecker <fweis...@gmail.com>
Cc: Jiri Olsa <jo...@redhat.com>
Cc: Mike Galbraith <efa...@gmx.de>
Cc: Namhyung Kim <namhy...@kernel.org>
Cc: Paul Mackerras <pau...@samba.org>
Cc: Peter Zijlstra <pet...@infradead.org>
Cc: Stephane Eranian <eran...@google.com>
Link: http://lkml.kernel.org/n/tip-yqdie3c8qvdgenwleri26...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <a...@redhat.com>
---
 tools/perf/util/evlist.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index d661f25..7847f38 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);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to