aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2016-04-11 14:49:11 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2016-04-11 21:18:19 -0400
commit44621819ddc9d5d0bfd0b0616c6cf33c94189b67 (patch)
treeffd8713f48d2e835debbea10b2809adc8e395c67
parentea4539652eccc87b14fbcbc90467ebcb87f02ddb (diff)
perf trace: Exclude the kernel part of the callchain leading to a syscall
The kernel parts are not that useful: # trace -m 512 -e nanosleep --call dwarf usleep 1 0.065 ( 0.065 ms): usleep/18732 nanosleep(rqtp: 0x7ffc4ee4e200) = 0 syscall_slow_exit_work ([kernel.kallsyms]) do_syscall_64 ([kernel.kallsyms]) return_from_SYSCALL_64 ([kernel.kallsyms]) __nanosleep (/usr/lib64/libc-2.22.so) usleep (/usr/lib64/libc-2.22.so) main (/usr/bin/usleep) __libc_start_main (/usr/lib64/libc-2.22.so) _start (/usr/bin/usleep) # So lets just use perf_event_attr.exclude_callchain_kernel to avoid collecting it in the ring buffer: # trace -m 512 -e nanosleep --call dwarf usleep 1 0.063 ( 0.063 ms): usleep/19212 nanosleep(rqtp: 0x7ffc3df10fb0) = 0 __nanosleep (/usr/lib64/libc-2.22.so) usleep (/usr/lib64/libc-2.22.so) main (/usr/bin/usleep) __libc_start_main (/usr/lib64/libc-2.22.so) _start (/usr/bin/usleep) # 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-qctu3gqhpim0dfbcp9d86c91@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/Documentation/perf-trace.txt3
-rw-r--r--tools/perf/builtin-trace.c13
2 files changed, 16 insertions, 0 deletions
diff --git a/tools/perf/Documentation/perf-trace.txt b/tools/perf/Documentation/perf-trace.txt
index ed485df16409..1bbcf305d233 100644
--- a/tools/perf/Documentation/perf-trace.txt
+++ b/tools/perf/Documentation/perf-trace.txt
@@ -123,6 +123,9 @@ 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--kernel-syscall-graph::
127 Show the kernel callchains on the syscall exit path.
128
126--event:: 129--event::
127 Trace other events, see 'perf list' for a complete list. 130 Trace other events, see 'perf list' for a complete list.
128 131
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 63a3cc9b717c..cfa5ce8fdb7b 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -159,6 +159,7 @@ struct trace {
159 bool show_comm; 159 bool show_comm;
160 bool show_tool_stats; 160 bool show_tool_stats;
161 bool trace_syscalls; 161 bool trace_syscalls;
162 bool kernel_syscallchains;
162 bool force; 163 bool force;
163 bool vfs_getname; 164 bool vfs_getname;
164 int trace_pgfaults; 165 int trace_pgfaults;
@@ -2661,6 +2662,15 @@ static int trace__add_syscall_newtp(struct trace *trace)
2661 perf_evlist__add(evlist, sys_enter); 2662 perf_evlist__add(evlist, sys_enter);
2662 perf_evlist__add(evlist, sys_exit); 2663 perf_evlist__add(evlist, sys_exit);
2663 2664
2665 if (trace->opts.callgraph_set && !trace->kernel_syscallchains) {
2666 /*
2667 * We're interested only in the user space callchain
2668 * leading to the syscall, allow overriding that for
2669 * debugging reasons using --kernel_syscall_callchains
2670 */
2671 sys_exit->attr.exclude_callchain_kernel = 1;
2672 }
2673
2664 trace->syscalls.events.sys_enter = sys_enter; 2674 trace->syscalls.events.sys_enter = sys_enter;
2665 trace->syscalls.events.sys_exit = sys_exit; 2675 trace->syscalls.events.sys_exit = sys_exit;
2666 2676
@@ -3221,6 +3231,7 @@ int cmd_trace(int argc, const char **argv, const char *prefix __maybe_unused)
3221 .output = stderr, 3231 .output = stderr,
3222 .show_comm = true, 3232 .show_comm = true,
3223 .trace_syscalls = true, 3233 .trace_syscalls = true,
3234 .kernel_syscallchains = false,
3224 }; 3235 };
3225 const char *output_name = NULL; 3236 const char *output_name = NULL;
3226 const char *ev_qualifier_str = NULL; 3237 const char *ev_qualifier_str = NULL;
@@ -3269,6 +3280,8 @@ int cmd_trace(int argc, const char **argv, const char *prefix __maybe_unused)
3269 OPT_CALLBACK(0, "call-graph", &trace.opts, 3280 OPT_CALLBACK(0, "call-graph", &trace.opts,
3270 "record_mode[,record_size]", record_callchain_help, 3281 "record_mode[,record_size]", record_callchain_help,
3271 &record_parse_callchain_opt), 3282 &record_parse_callchain_opt),
3283 OPT_BOOLEAN(0, "kernel-syscall-graph", &trace.kernel_syscallchains,
3284 "Show the kernel callchains on the syscall exit path"),
3272 OPT_UINTEGER(0, "proc-map-timeout", &trace.opts.proc_map_timeout, 3285 OPT_UINTEGER(0, "proc-map-timeout", &trace.opts.proc_map_timeout,
3273 "per thread proc mmap processing timeout in ms"), 3286 "per thread proc mmap processing timeout in ms"),
3274 OPT_END() 3287 OPT_END()