Skip to content

Commit

Permalink
perf trace: Provide a better explanation when mmap fails
Browse files Browse the repository at this point in the history
If we ask for a mmap lenght than the max configured via the relevant
sysctl, provide a better warning, instead of just expanding the EPERM
returned:

[acme@ssdandy ~]$ trace -m 256 -e nanosleep sleep 2
Error:	Operation not permitted.
Hint:	Check /proc/sys/kernel/perf_event_mlock_kb (516 kB) setting.
Hint:	Tried using 1028 kB.
Hint:	Try using a bigger -m/--mmap-pages value.

[acme@ssdandy ~]$ trace -m 128 -e nanosleep sleep 2
  2001.280 (2000.403 ms): nanosleep(rqtp: 0x7fff89a8a7f0) = 0
[acme@ssdandy ~]$

An upcoming patch will autotune the request for non-root users when -m
is not used.

Cc: Adrian Hunter <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Don Zickus <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Mike Galbraith <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Stephane Eranian <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
  • Loading branch information
acmel committed Dec 11, 2014
1 parent 956fa57 commit e09b18d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions tools/perf/builtin-trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -2045,7 +2045,6 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
unsigned long before;
const bool forks = argc > 0;
bool draining = false;
char sbuf[STRERR_BUFSIZE];

trace->live = true;

Expand Down Expand Up @@ -2106,11 +2105,8 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
goto out_error_open;

err = perf_evlist__mmap(evlist, trace->opts.mmap_pages, false);
if (err < 0) {
fprintf(trace->output, "Couldn't mmap the events: %s\n",
strerror_r(errno, sbuf, sizeof(sbuf)));
goto out_delete_evlist;
}
if (err < 0)
goto out_error_mmap;

perf_evlist__enable(evlist);

Expand Down Expand Up @@ -2210,6 +2206,10 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
perf_evlist__strerror_tp(evlist, errno, errbuf, sizeof(errbuf));
goto out_error;

out_error_mmap:
perf_evlist__strerror_mmap(evlist, errno, errbuf, sizeof(errbuf));
goto out_error;

out_error_open:
perf_evlist__strerror_open(evlist, errno, errbuf, sizeof(errbuf));

Expand Down

0 comments on commit e09b18d

Please sign in to comment.