Commit f633903a authored by Steven Rostedt's avatar Steven Rostedt Committed by Steven Rostedt

tracing: make tracing_reset safe for external use

Reseting the trace buffer without first disabling the buffer and
waiting for any writers to complete, can corrupt the ring buffer.

This patch makes the external version of tracing_reset safe from
corruption by disabling the ring buffer and calling synchronize_sched.

This version can no longer be called from interrupt context. But all those
callers have been removed.
Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
parent 2f26ebd5
...@@ -641,13 +641,26 @@ void unregister_tracer(struct tracer *type) ...@@ -641,13 +641,26 @@ void unregister_tracer(struct tracer *type)
mutex_unlock(&trace_types_lock); mutex_unlock(&trace_types_lock);
} }
void tracing_reset(struct trace_array *tr, int cpu) static void __tracing_reset(struct trace_array *tr, int cpu)
{ {
ftrace_disable_cpu(); ftrace_disable_cpu();
ring_buffer_reset_cpu(tr->buffer, cpu); ring_buffer_reset_cpu(tr->buffer, cpu);
ftrace_enable_cpu(); ftrace_enable_cpu();
} }
void tracing_reset(struct trace_array *tr, int cpu)
{
struct ring_buffer *buffer = tr->buffer;
ring_buffer_record_disable(buffer);
/* Make sure all commits have finished */
synchronize_sched();
__tracing_reset(tr, cpu);
ring_buffer_record_enable(buffer);
}
void tracing_reset_online_cpus(struct trace_array *tr) void tracing_reset_online_cpus(struct trace_array *tr)
{ {
struct ring_buffer *buffer = tr->buffer; struct ring_buffer *buffer = tr->buffer;
...@@ -661,7 +674,7 @@ void tracing_reset_online_cpus(struct trace_array *tr) ...@@ -661,7 +674,7 @@ void tracing_reset_online_cpus(struct trace_array *tr)
tr->time_start = ftrace_now(tr->cpu); tr->time_start = ftrace_now(tr->cpu);
for_each_online_cpu(cpu) for_each_online_cpu(cpu)
tracing_reset(tr, cpu); __tracing_reset(tr, cpu);
ring_buffer_record_enable(buffer); ring_buffer_record_enable(buffer);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment