aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2009-06-17 00:39:43 -0400
committerSteven Rostedt <rostedt@goodmis.org>2009-06-17 14:16:23 -0400
commitd47882078f05c2cb46b85f1e12a58ed9315b9d63 (patch)
treead10f2172384d2112b6e8136b9981a0eb813539b /kernel/trace
parent5f78abeebbf0a80975d719e11374535ca15396cb (diff)
ring-buffer: add locks around rb_per_cpu_empty
The checking of whether the buffer is empty or not needs to be serialized among the readers. Add the reader spin lock around it. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace')
-rw-r--r--kernel/trace/ring_buffer.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index 2e99dba6dc48..969f7cbe8e93 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -2756,12 +2756,17 @@ EXPORT_SYMBOL_GPL(ring_buffer_reset);
2756int ring_buffer_empty(struct ring_buffer *buffer) 2756int ring_buffer_empty(struct ring_buffer *buffer)
2757{ 2757{
2758 struct ring_buffer_per_cpu *cpu_buffer; 2758 struct ring_buffer_per_cpu *cpu_buffer;
2759 unsigned long flags;
2759 int cpu; 2760 int cpu;
2761 int ret;
2760 2762
2761 /* yes this is racy, but if you don't like the race, lock the buffer */ 2763 /* yes this is racy, but if you don't like the race, lock the buffer */
2762 for_each_buffer_cpu(buffer, cpu) { 2764 for_each_buffer_cpu(buffer, cpu) {
2763 cpu_buffer = buffer->buffers[cpu]; 2765 cpu_buffer = buffer->buffers[cpu];
2764 if (!rb_per_cpu_empty(cpu_buffer)) 2766 spin_lock_irqsave(&cpu_buffer->reader_lock, flags);
2767 ret = rb_per_cpu_empty(cpu_buffer);
2768 spin_unlock_irqrestore(&cpu_buffer->reader_lock, flags);
2769 if (!ret)
2765 return 0; 2770 return 0;
2766 } 2771 }
2767 2772
@@ -2777,14 +2782,16 @@ EXPORT_SYMBOL_GPL(ring_buffer_empty);
2777int ring_buffer_empty_cpu(struct ring_buffer *buffer, int cpu) 2782int ring_buffer_empty_cpu(struct ring_buffer *buffer, int cpu)
2778{ 2783{
2779 struct ring_buffer_per_cpu *cpu_buffer; 2784 struct ring_buffer_per_cpu *cpu_buffer;
2785 unsigned long flags;
2780 int ret; 2786 int ret;
2781 2787
2782 if (!cpumask_test_cpu(cpu, buffer->cpumask)) 2788 if (!cpumask_test_cpu(cpu, buffer->cpumask))
2783 return 1; 2789 return 1;
2784 2790
2785 cpu_buffer = buffer->buffers[cpu]; 2791 cpu_buffer = buffer->buffers[cpu];
2792 spin_lock_irqsave(&cpu_buffer->reader_lock, flags);
2786 ret = rb_per_cpu_empty(cpu_buffer); 2793 ret = rb_per_cpu_empty(cpu_buffer);
2787 2794 spin_unlock_irqrestore(&cpu_buffer->reader_lock, flags);
2788 2795
2789 return ret; 2796 return ret;
2790} 2797}