ring-buffer: do not reset while in a commit
authorSteven Rostedt <srostedt@redhat.com>
Wed, 2 Sep 2009 13:59:48 +0000 (09:59 -0400)
committerSteven Rostedt <rostedt@goodmis.org>
Fri, 4 Sep 2009 15:15:08 +0000 (11:15 -0400)
The callers of reset must ensure that no commit can be taking place
at the time of the reset. If it does then we may corrupt the ring buffer.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
kernel/trace/ring_buffer.c

index da2c59d8f486c11c6e3db8759c15e78805a666f0..79d6012bb1f19a4a6b0835546a82d2cf9ac7e991 100644 (file)
@@ -3373,12 +3373,16 @@ void ring_buffer_reset_cpu(struct ring_buffer *buffer, int cpu)
 
        spin_lock_irqsave(&cpu_buffer->reader_lock, flags);
 
+       if (RB_WARN_ON(cpu_buffer, local_read(&cpu_buffer->committing)))
+               goto out;
+
        __raw_spin_lock(&cpu_buffer->lock);
 
        rb_reset_cpu(cpu_buffer);
 
        __raw_spin_unlock(&cpu_buffer->lock);
 
+ out:
        spin_unlock_irqrestore(&cpu_buffer->reader_lock, flags);
 
        atomic_dec(&cpu_buffer->record_disabled);