diff options
Diffstat (limited to 'kernel/trace')
-rw-r--r-- | kernel/trace/ring_buffer.c | 11 |
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); | |||
2756 | int ring_buffer_empty(struct ring_buffer *buffer) | 2756 | int 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); | |||
2777 | int ring_buffer_empty_cpu(struct ring_buffer *buffer, int cpu) | 2782 | int 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 | } |