aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2016-04-15 16:52:34 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2016-04-15 16:52:34 -0400
commitf3e459d16a8493b617ccf2a940330279679e0291 (patch)
treec6cc841dcb256d0ea77b0ab56b05fe0b344e4aab
parentf5e7150cd9a7779a54b192d21afb9245384db8bc (diff)
perf trace: Bump --mmap-pages when --call-graph is used by the root user
To reduce the chances we'll overflow the mmap buffer, manual fine tuning trumps this. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Milian Wolff <milian.wolff@kdab.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/n/tip-wxygbxmp1v9mng1ea28wet02@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/Documentation/perf-trace.txt4
-rw-r--r--tools/perf/builtin-trace.c10
2 files changed, 13 insertions, 1 deletions
diff --git a/tools/perf/Documentation/perf-trace.txt b/tools/perf/Documentation/perf-trace.txt
index 146c6db21cbf..c075c002eaa4 100644
--- a/tools/perf/Documentation/perf-trace.txt
+++ b/tools/perf/Documentation/perf-trace.txt
@@ -123,6 +123,10 @@ the thread executes on the designated CPUs. Default is to monitor all CPUs.
123 man pages for details. The ones that are most useful in 'perf trace' 123 man pages for details. The ones that are most useful in 'perf trace'
124 are 'dwarf' and 'lbr', where available, try: 'perf trace --call-graph dwarf'. 124 are 'dwarf' and 'lbr', where available, try: 'perf trace --call-graph dwarf'.
125 125
126 Using this will, for the root user, bump the value of --mmap-pages to 4
127 times the maximum for non-root users, based on the kernel.perf_event_mlock_kb
128 sysctl. This is done only if the user doesn't specify a --mmap-pages value.
129
126--kernel-syscall-graph:: 130--kernel-syscall-graph::
127 Show the kernel callchains on the syscall exit path. 131 Show the kernel callchains on the syscall exit path.
128 132
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 19f5100acc1d..026ec0c749b0 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -3110,6 +3110,7 @@ int cmd_trace(int argc, const char **argv, const char *prefix __maybe_unused)
3110 OPT_END() 3110 OPT_END()
3111 }; 3111 };
3112 bool max_stack_user_set = true; 3112 bool max_stack_user_set = true;
3113 bool mmap_pages_user_set = true;
3113 const char * const trace_subcommands[] = { "record", NULL }; 3114 const char * const trace_subcommands[] = { "record", NULL };
3114 int err; 3115 int err;
3115 char bf[BUFSIZ]; 3116 char bf[BUFSIZ];
@@ -3143,6 +3144,9 @@ int cmd_trace(int argc, const char **argv, const char *prefix __maybe_unused)
3143 trace.opts.sample_time = true; 3144 trace.opts.sample_time = true;
3144 } 3145 }
3145 3146
3147 if (trace.opts.mmap_pages == UINT_MAX)
3148 mmap_pages_user_set = false;
3149
3146 if (trace.max_stack == UINT_MAX) { 3150 if (trace.max_stack == UINT_MAX) {
3147 trace.max_stack = PERF_MAX_STACK_DEPTH; 3151 trace.max_stack = PERF_MAX_STACK_DEPTH;
3148 max_stack_user_set = false; 3152 max_stack_user_set = false;
@@ -3153,8 +3157,12 @@ int cmd_trace(int argc, const char **argv, const char *prefix __maybe_unused)
3153 record_opts__parse_callchain(&trace.opts, &callchain_param, "dwarf", false); 3157 record_opts__parse_callchain(&trace.opts, &callchain_param, "dwarf", false);
3154#endif 3158#endif
3155 3159
3156 if (trace.opts.callgraph_set) 3160 if (trace.opts.callgraph_set) {
3161 if (!mmap_pages_user_set && geteuid() == 0)
3162 trace.opts.mmap_pages = perf_event_mlock_kb_in_pages() * 4;
3163
3157 symbol_conf.use_callchain = true; 3164 symbol_conf.use_callchain = true;
3165 }
3158 3166
3159 if (trace.evlist->nr_entries > 0) 3167 if (trace.evlist->nr_entries > 0)
3160 evlist__set_evsel_handler(trace.evlist, trace__event_handler); 3168 evlist__set_evsel_handler(trace.evlist, trace__event_handler);