diff options
author | Steven Rostedt <srostedt@redhat.com> | 2010-03-12 19:48:41 -0500 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2010-03-12 20:29:20 -0500 |
commit | 283740c619d211e34572cc93c8cdba92ccbdb9cc (patch) | |
tree | 3bdce475017ff9a5fe82c6d214d27b27e555320c /kernel/trace | |
parent | ea14eb714041d40fcc5180b5a586034503650149 (diff) |
tracing: Use same local variable when resetting the ring buffer
In the ftrace code that resets the ring buffer it references the
buffer with a local variable, but then uses the tr->buffer as the
parameter to reset. If the wakeup tracer is running, which can
switch the tr->buffer with the max saved buffer, this can break
the requirement of disabling the buffer before the reset.
buffer = tr->buffer;
ring_buffer_record_disable(buffer);
synchronize_sched();
__tracing_reset(tr->buffer, cpu);
If the tr->buffer is swapped, then the reset is not happening to the
buffer that was disabled. This will cause the ring buffer to fail.
Found with Li Zefan's ftrace_stress_test.
Cc: stable@kernel.org
Reported-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace')
-rw-r--r-- | kernel/trace/trace.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 6af8d7bc953b..60de37bd0f75 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
@@ -840,10 +840,10 @@ out: | |||
840 | mutex_unlock(&trace_types_lock); | 840 | mutex_unlock(&trace_types_lock); |
841 | } | 841 | } |
842 | 842 | ||
843 | static void __tracing_reset(struct trace_array *tr, int cpu) | 843 | static void __tracing_reset(struct ring_buffer *buffer, int cpu) |
844 | { | 844 | { |
845 | ftrace_disable_cpu(); | 845 | ftrace_disable_cpu(); |
846 | ring_buffer_reset_cpu(tr->buffer, cpu); | 846 | ring_buffer_reset_cpu(buffer, cpu); |
847 | ftrace_enable_cpu(); | 847 | ftrace_enable_cpu(); |
848 | } | 848 | } |
849 | 849 | ||
@@ -855,7 +855,7 @@ void tracing_reset(struct trace_array *tr, int cpu) | |||
855 | 855 | ||
856 | /* Make sure all commits have finished */ | 856 | /* Make sure all commits have finished */ |
857 | synchronize_sched(); | 857 | synchronize_sched(); |
858 | __tracing_reset(tr, cpu); | 858 | __tracing_reset(buffer, cpu); |
859 | 859 | ||
860 | ring_buffer_record_enable(buffer); | 860 | ring_buffer_record_enable(buffer); |
861 | } | 861 | } |
@@ -873,7 +873,7 @@ void tracing_reset_online_cpus(struct trace_array *tr) | |||
873 | tr->time_start = ftrace_now(tr->cpu); | 873 | tr->time_start = ftrace_now(tr->cpu); |
874 | 874 | ||
875 | for_each_online_cpu(cpu) | 875 | for_each_online_cpu(cpu) |
876 | __tracing_reset(tr, cpu); | 876 | __tracing_reset(buffer, cpu); |
877 | 877 | ||
878 | ring_buffer_record_enable(buffer); | 878 | ring_buffer_record_enable(buffer); |
879 | } | 879 | } |