aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/ring_buffer.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-12-11 21:18:58 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-12-11 21:18:58 -0500
commitda830e589a45f0c42eef6f3cbd07275f8893f181 (patch)
treeb241c86b8a0f9acdef4b90f69ddd200548e91f2c /kernel/trace/ring_buffer.c
parent090f8ccba37034cec5a5972a70abeaae7eb0222b (diff)
parent08cd2a6960ae2e1aa7f44b44ebafa84f503a2dd1 (diff)
Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull perf fixes from Ingo Molnar: "These are late-v3.7 pending fixes for tracing." Fix up trivial conflict in kernel/trace/ring_buffer.c: the NULL pointer fix clashed with the change of type of the 'ret' variable. * 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: ring-buffer: Fix race between integrity check and readers ring-buffer: Fix NULL pointer if rb_set_head_page() fails ftrace: Clear bits properly in reset_iter_read()
Diffstat (limited to 'kernel/trace/ring_buffer.c')
-rw-r--r--kernel/trace/ring_buffer.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index 3c7834c24e54..ce8514feedcd 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -1397,6 +1397,8 @@ rb_insert_pages(struct ring_buffer_per_cpu *cpu_buffer)
1397 struct list_head *head_page_with_bit; 1397 struct list_head *head_page_with_bit;
1398 1398
1399 head_page = &rb_set_head_page(cpu_buffer)->list; 1399 head_page = &rb_set_head_page(cpu_buffer)->list;
1400 if (!head_page)
1401 break;
1400 prev_page = head_page->prev; 1402 prev_page = head_page->prev;
1401 1403
1402 first_page = pages->next; 1404 first_page = pages->next;
@@ -2937,7 +2939,7 @@ u64 ring_buffer_oldest_event_ts(struct ring_buffer *buffer, int cpu)
2937 unsigned long flags; 2939 unsigned long flags;
2938 struct ring_buffer_per_cpu *cpu_buffer; 2940 struct ring_buffer_per_cpu *cpu_buffer;
2939 struct buffer_page *bpage; 2941 struct buffer_page *bpage;
2940 u64 ret; 2942 u64 ret = 0;
2941 2943
2942 if (!cpumask_test_cpu(cpu, buffer->cpumask)) 2944 if (!cpumask_test_cpu(cpu, buffer->cpumask))
2943 return 0; 2945 return 0;
@@ -2952,7 +2954,8 @@ u64 ring_buffer_oldest_event_ts(struct ring_buffer *buffer, int cpu)
2952 bpage = cpu_buffer->reader_page; 2954 bpage = cpu_buffer->reader_page;
2953 else 2955 else
2954 bpage = rb_set_head_page(cpu_buffer); 2956 bpage = rb_set_head_page(cpu_buffer);
2955 ret = bpage->page->time_stamp; 2957 if (bpage)
2958 ret = bpage->page->time_stamp;
2956 raw_spin_unlock_irqrestore(&cpu_buffer->reader_lock, flags); 2959 raw_spin_unlock_irqrestore(&cpu_buffer->reader_lock, flags);
2957 2960
2958 return ret; 2961 return ret;
@@ -3288,6 +3291,8 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
3288 * Splice the empty reader page into the list around the head. 3291 * Splice the empty reader page into the list around the head.
3289 */ 3292 */
3290 reader = rb_set_head_page(cpu_buffer); 3293 reader = rb_set_head_page(cpu_buffer);
3294 if (!reader)
3295 goto out;
3291 cpu_buffer->reader_page->list.next = rb_list_head(reader->list.next); 3296 cpu_buffer->reader_page->list.next = rb_list_head(reader->list.next);
3292 cpu_buffer->reader_page->list.prev = reader->list.prev; 3297 cpu_buffer->reader_page->list.prev = reader->list.prev;
3293 3298
@@ -3806,12 +3811,17 @@ void
3806ring_buffer_read_finish(struct ring_buffer_iter *iter) 3811ring_buffer_read_finish(struct ring_buffer_iter *iter)
3807{ 3812{
3808 struct ring_buffer_per_cpu *cpu_buffer = iter->cpu_buffer; 3813 struct ring_buffer_per_cpu *cpu_buffer = iter->cpu_buffer;
3814 unsigned long flags;
3809 3815
3810 /* 3816 /*
3811 * Ring buffer is disabled from recording, here's a good place 3817 * Ring buffer is disabled from recording, here's a good place
3812 * to check the integrity of the ring buffer. 3818 * to check the integrity of the ring buffer.
3819 * Must prevent readers from trying to read, as the check
3820 * clears the HEAD page and readers require it.
3813 */ 3821 */
3822 raw_spin_lock_irqsave(&cpu_buffer->reader_lock, flags);
3814 rb_check_pages(cpu_buffer); 3823 rb_check_pages(cpu_buffer);
3824 raw_spin_unlock_irqrestore(&cpu_buffer->reader_lock, flags);
3815 3825
3816 atomic_dec(&cpu_buffer->record_disabled); 3826 atomic_dec(&cpu_buffer->record_disabled);
3817 atomic_dec(&cpu_buffer->buffer->resize_disabled); 3827 atomic_dec(&cpu_buffer->buffer->resize_disabled);