[ 21/99] tracing: Remove locking trace_types_lock from tracing_reset_all_online_cpus()

From: Greg Kroah-Hartman
Date: Fri Aug 02 2013 - 06:50:10 EST

3.10-stable review patch. If anyone has any objections, please let me know.


From: "Steven Rostedt (Red Hat)" <rostedt@xxxxxxxxxxx>

commit 09d8091c024ec88d1541d93eb8ddb2bd5cf10c39 upstream.

Commit a82274151af "tracing: Protect ftrace_trace_arrays list in trace_events.c"
added taking the trace_types_lock mutex in trace_events.c as there were
several locations that needed it for protection. Unfortunately, it also
encapsulated a call to tracing_reset_all_online_cpus() which also takes
the trace_types_lock, causing a deadlock.

This happens when a module has tracepoints and has been traced. When the
module is removed, the trace events module notifier will grab the
trace_types_lock, do a bunch of clean ups, and also clears the buffer
by calling tracing_reset_all_online_cpus. This doesn't happen often
which explains why it wasn't caught right away.

Commit a82274151af was marked for stable, which means this must be
sent to stable too.

Link: http://lkml.kernel.org/r/51EEC646.7070306@xxxxxxxxxxxx

Reported-by: Arend van Spril <arend@xxxxxxxxxxxx>
Tested-by: Arend van Spriel <arend@xxxxxxxxxxxx>
Cc: Alexander Z Lam <azl@xxxxxxxxxx>
Cc: Vaibhav Nagarnaik <vnagarnaik@xxxxxxxxxx>
Cc: David Sharp <dhsharp@xxxxxxxxxx>
Signed-off-by: Steven Rostedt <rostedt@xxxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>

kernel/trace/trace.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -1163,18 +1163,17 @@ void tracing_reset_current(int cpu)
tracing_reset(&global_trace.trace_buffer, cpu);

+/* Must have trace_types_lock held */
void tracing_reset_all_online_cpus(void)
struct trace_array *tr;

- mutex_lock(&trace_types_lock);
list_for_each_entry(tr, &ftrace_trace_arrays, list) {
- mutex_unlock(&trace_types_lock);

#define SAVED_CMDLINES 128

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/