linux/kernel/trace
Steven Rostedt (Red Hat) 70b3d6c5aa tracing: Skip more functions when doing stack tracing of events
[ Upstream commit be54f69c26 ]

 # echo 1 > options/stacktrace
 # echo 1 > events/sched/sched_switch/enable
 # cat trace
          <idle>-0     [002] d..2  1982.525169: <stack trace>
 => save_stack_trace
 => __ftrace_trace_stack
 => trace_buffer_unlock_commit_regs
 => event_trigger_unlock_commit
 => trace_event_buffer_commit
 => trace_event_raw_event_sched_switch
 => __schedule
 => schedule
 => schedule_preempt_disabled
 => cpu_startup_entry
 => start_secondary

The above shows that we are seeing 6 functions before ever making it to the
caller of the sched_switch event.

 # echo stacktrace > events/sched/sched_switch/trigger
 # cat trace
          <idle>-0     [002] d..3  2146.335208: <stack trace>
 => trace_event_buffer_commit
 => trace_event_raw_event_sched_switch
 => __schedule
 => schedule
 => schedule_preempt_disabled
 => cpu_startup_entry
 => start_secondary

The stacktrace trigger isn't as bad, because it adds its own skip to the
stacktracing, but still has two events extra.

One issue is that if the stacktrace passes its own "regs" then there should
be no addition to the skip, as the regs will not include the functions being
called. This was an issue that was fixed by commit 7717c6be69 ("tracing:
Fix stacktrace skip depth in trace_buffer_unlock_commit_regs()" as adding
the skip number for kprobes made the probes not have any stack at all.

But since this is only an issue when regs is being used, a skip should be
added if regs is NULL. Now we have:

 # echo 1 > options/stacktrace
 # echo 1 > events/sched/sched_switch/enable
 # cat trace
          <idle>-0     [000] d..2  1297.676333: <stack trace>
 => __schedule
 => schedule
 => schedule_preempt_disabled
 => cpu_startup_entry
 => rest_init
 => start_kernel
 => x86_64_start_reservations
 => x86_64_start_kernel

 # echo stacktrace > events/sched/sched_switch/trigger
 # cat trace
          <idle>-0     [002] d..3  1370.759745: <stack trace>
 => __schedule
 => schedule
 => schedule_preempt_disabled
 => cpu_startup_entry
 => start_secondary

And kprobes are not touched.

Reported-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2018-11-10 07:41:35 -08:00
..
blktrace.c tracing/blktrace: Fix to allow setting same value 2018-09-09 20:04:34 +02:00
bpf_trace.c
ftrace.c ftrace: Remove incorrect setting of glob search field 2018-02-16 20:09:47 +01:00
Kconfig
Makefile Makefile: Mute warning for __builtin_return_address(>0) for tracing only 2016-09-30 10:18:35 +02:00
power-traces.c
ring_buffer_benchmark.c
ring_buffer.c ring-buffer: Allow for rescheduling when removing pages 2018-09-29 03:08:52 -07:00
rpm-traces.c
trace_benchmark.c
trace_benchmark.h
trace_branch.c
trace_clock.c
trace_entries.h
trace_event_perf.c
trace_events_filter_test.h
trace_events_filter.c tracing: Fix regex_match_front() to not over compare the test string 2018-05-16 10:06:51 +02:00
trace_events_trigger.c tracing: Fix possible double free in event_enable_trigger_func() 2018-08-06 16:24:29 +02:00
trace_events.c tracing: Fix converting enum's from the map in trace_event_eval_update() 2018-01-23 19:50:16 +01:00
trace_export.c
trace_functions_graph.c tracing: Fix missing return symbol in function_graph output 2018-07-11 16:03:48 +02:00
trace_functions.c
trace_irqsoff.c
trace_kdb.c
trace_kprobe.c tracing: Quiet gcc warning about maybe unused link variable 2018-08-06 16:24:30 +02:00
trace_mmiotrace.c
trace_nop.c
trace_output.c
trace_output.h
trace_printk.c
trace_probe.c tracing: probeevent: Fix to support minus offset from symbol 2018-03-28 18:40:15 +02:00
trace_probe.h tracing: probeevent: Fix to support minus offset from symbol 2018-03-28 18:40:15 +02:00
trace_sched_switch.c
trace_sched_wakeup.c
trace_selftest_dynamic.c
trace_selftest.c ftrace: Fix selftest goto location on error 2017-09-27 11:00:16 +02:00
trace_seq.c
trace_stack.c
trace_stat.c
trace_stat.h
trace_syscalls.c
trace_uprobe.c uprobes: Use synchronize_rcu() not synchronize_sched() 2018-09-09 20:04:34 +02:00
trace.c tracing: Skip more functions when doing stack tracing of events 2018-11-10 07:41:35 -08:00
trace.h