Skip to content

Commit

Permalink
tracing: disable buffers and synchronize_sched before resetting
Browse files Browse the repository at this point in the history
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@goodmis.org>
  • Loading branch information
Steven Rostedt authored and Steven Rostedt committed Sep 4, 2009
1 parent b8de7bd commit 621968c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions kernel/trace/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

for_each_online_cpu(cpu)
tracing_reset(tr, cpu);

ring_buffer_record_enable(buffer);
}

void tracing_reset_current(int cpu)
Expand Down

0 comments on commit 621968c

Please sign in to comment.