kernel_optimize_test/kernel/trace
Steven Rostedt b1cff0ad10 ftrace: Add internal recursive checks
Witold reported a reboot caused by the selftests of the dynamic function
tracer. He sent me a config and I used ktest to do a config_bisect on it
(as my config did not cause the crash). It pointed out that the problem
config was CONFIG_PROVE_RCU.

What happened was that if multiple callbacks are attached to the
function tracer, we iterate a list of callbacks. Because the list is
managed by synchronize_sched() and preempt_disable, the access to the
pointers uses rcu_dereference_raw().

When PROVE_RCU is enabled, the rcu_dereference_raw() calls some
debugging functions, which happen to be traced. The tracing of the debug
function would then call rcu_dereference_raw() which would then call the
debug function and then... well you get the idea.

I first wrote two different patches to solve this bug.

1) add a __rcu_dereference_raw() that would not do any checks.
2) add notrace to the offending debug functions.

Both of these patches worked.

Talking with Paul McKenney on IRC, he suggested to add recursion
detection instead. This seemed to be a better solution, so I decided to
implement it. As the task_struct already has a trace_recursion to detect
recursion in the ring buffer, and that has a very small number it
allows, I decided to use that same variable to add flags that can detect
the recursion inside the infrastructure of the function tracer.

I plan to change it so that the task struct bit can be checked in
mcount, but as that requires changes to all archs, I will hold that off
to the next merge window.

Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Link: http://lkml.kernel.org/r/1306348063.1465.116.camel@gandalf.stny.rr.com
Reported-by: Witold Baryluk <baryluk@smp.if.uj.edu.pl>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
2011-05-25 22:13:49 -04:00
..
blktrace.c block: make unplug timer trace event correspond to the schedule() unplug 2011-04-16 13:51:05 +02:00
ftrace.c ftrace: Add internal recursive checks 2011-05-25 22:13:49 -04:00
Kconfig ftrace: Build without frame pointers on Microblaze 2011-04-21 09:06:24 -04:00
Makefile
power-traces.c
ring_buffer_benchmark.c
ring_buffer.c ftrace: Add internal recursive checks 2011-05-25 22:13:49 -04:00
trace_branch.c
trace_clock.c Fix common misspellings 2011-03-31 11:26:23 -03:00
trace_entries.h Fix common misspellings 2011-03-31 11:26:23 -03:00
trace_event_perf.c
trace_events_filter.c trace, filters: Initialize the match variable in process_ops() properly 2011-03-18 14:41:27 +01:00
trace_events.c tracing: Have event with function tracer check error return 2011-05-25 22:13:39 -04:00
trace_export.c
trace_functions_graph.c Fix common misspellings 2011-03-31 11:26:23 -03:00
trace_functions.c ftrace: Implement separate user function filtering 2011-05-18 15:29:50 -04:00
trace_irqsoff.c ftrace: Implement separate user function filtering 2011-05-18 15:29:50 -04:00
trace_kdb.c
trace_kprobe.c sched: Get rid of lock_depth 2011-04-24 13:18:38 +02:00
trace_mmiotrace.c
trace_nop.c
trace_output.c tracing: Add __print_symbolic_u64 to avoid warnings on 32bit machine 2011-05-25 22:13:44 -04:00
trace_output.h
trace_printk.c tracing: Print trace_bprintk() formats for modules too 2011-04-04 12:18:24 -04:00
trace_sched_switch.c
trace_sched_wakeup.c ftrace: Implement separate user function filtering 2011-05-18 15:29:50 -04:00
trace_selftest_dynamic.c ftrace: Add self-tests for multiple function trace users 2011-05-18 19:24:51 -04:00
trace_selftest.c ftrace: Add self-tests for multiple function trace users 2011-05-18 19:24:51 -04:00
trace_stack.c ftrace: Implement separate user function filtering 2011-05-18 15:29:50 -04:00
trace_stat.c
trace_stat.h
trace_syscalls.c
trace_workqueue.c
trace.c Merge commit 'v2.6.39-rc7' into perf/core 2011-05-10 17:05:45 +02:00
trace.h ftrace: Add internal recursive checks 2011-05-25 22:13:49 -04:00