[PATCH 10/18] tracing: disable buffers and synchronize_sched before resetting

From: Steven Rostedt
Date: Fri Sep 04 2009 - 20:03:32 EST

From: Steven Rostedt <srostedt@xxxxxxxxxx>

Resetting the ring buffers while traces are happening can corrupt
the ring buffer and disable it (no kernel crash to worry about).

The safest thing to do is disable the ring buffers, call synchronize_sched()
to wait for all current writers to finish and then reset the buffer.

Signed-off-by: Steven Rostedt <rostedt@xxxxxxxxxxx>
kernel/trace/trace.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index e521f1e..9110329 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -658,12 +658,20 @@ void tracing_reset(struct trace_array *tr, int cpu)

void tracing_reset_online_cpus(struct trace_array *tr)
+ struct ring_buffer *buffer = tr->buffer;
int cpu;

+ ring_buffer_record_disable(buffer);
+ /* Make sure all commits have finished */
+ synchronize_sched();
tr->time_start = ftrace_now(tr->cpu);

tracing_reset(tr, cpu);
+ ring_buffer_record_enable(buffer);

void tracing_reset_current(int cpu)

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/