aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorRobert Richter <robert.richter@amd.com>2009-07-30 13:19:18 -0400
committerIngo Molnar <mingo@elte.hu>2009-08-06 08:20:25 -0400
commit469535a598f28c13a2a42037e1b778f671af1d16 (patch)
tree907a3434e87bdab3f37f3c965a230af7af9bdb30 /kernel
parent3f6e968ef4e1d8d93d8a8505461b0e50a9e97ad8 (diff)
ring-buffer: Fix advance of reader in rb_buffer_peek()
When calling rb_buffer_peek() from ring_buffer_consume() and a padding event is returned, the function rb_advance_reader() is called twice. This may lead to missing samples or under high workloads to the warning below. This patch fixes this. If a padding event is returned by rb_buffer_peek() it will be consumed by the calling function now. Also, I simplified some code in ring_buffer_consume(). ------------[ cut here ]------------ WARNING: at /dev/shm/.source/linux/kernel/trace/ring_buffer.c:2289 rb_advance_reader+0x2e/0xc5() Hardware name: Anaheim Modules linked in: Pid: 29, comm: events/2 Tainted: G W 2.6.31-rc3-oprofile-x86_64-standard-00059-g5050dc2 #1 Call Trace: [<ffffffff8106776f>] ? rb_advance_reader+0x2e/0xc5 [<ffffffff81039ffe>] warn_slowpath_common+0x77/0x8f [<ffffffff8103a025>] warn_slowpath_null+0xf/0x11 [<ffffffff8106776f>] rb_advance_reader+0x2e/0xc5 [<ffffffff81068bda>] ring_buffer_consume+0xa0/0xd2 [<ffffffff81326933>] op_cpu_buffer_read_entry+0x21/0x9e [<ffffffff810be3af>] ? __find_get_block+0x4b/0x165 [<ffffffff8132749b>] sync_buffer+0xa5/0x401 [<ffffffff810be3af>] ? __find_get_block+0x4b/0x165 [<ffffffff81326c1b>] ? wq_sync_buffer+0x0/0x78 [<ffffffff81326c76>] wq_sync_buffer+0x5b/0x78 [<ffffffff8104aa30>] worker_thread+0x113/0x1ac [<ffffffff8104dd95>] ? autoremove_wake_function+0x0/0x38 [<ffffffff8104a91d>] ? worker_thread+0x0/0x1ac [<ffffffff8104dc9a>] kthread+0x88/0x92 [<ffffffff8100bdba>] child_rip+0xa/0x20 [<ffffffff8104dc12>] ? kthread+0x0/0x92 [<ffffffff8100bdb0>] ? child_rip+0x0/0x20 ---[ end trace f561c0a58fcc89bd ]--- Cc: Steven Rostedt <rostedt@goodmis.org> Cc: <stable@kernel.org> Signed-off-by: Robert Richter <robert.richter@amd.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/trace/ring_buffer.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index 2606cee433d..d4d3580a894 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -2383,7 +2383,6 @@ rb_buffer_peek(struct ring_buffer *buffer, int cpu, u64 *ts)
2383 * the box. Return the padding, and we will release 2383 * the box. Return the padding, and we will release
2384 * the current locks, and try again. 2384 * the current locks, and try again.
2385 */ 2385 */
2386 rb_advance_reader(cpu_buffer);
2387 return event; 2386 return event;
2388 2387
2389 case RINGBUF_TYPE_TIME_EXTEND: 2388 case RINGBUF_TYPE_TIME_EXTEND:
@@ -2519,6 +2518,8 @@ ring_buffer_peek(struct ring_buffer *buffer, int cpu, u64 *ts)
2519 if (dolock) 2518 if (dolock)
2520 spin_lock(&cpu_buffer->reader_lock); 2519 spin_lock(&cpu_buffer->reader_lock);
2521 event = rb_buffer_peek(buffer, cpu, ts); 2520 event = rb_buffer_peek(buffer, cpu, ts);
2521 if (event && event->type_len == RINGBUF_TYPE_PADDING)
2522 rb_advance_reader(cpu_buffer);
2522 if (dolock) 2523 if (dolock)
2523 spin_unlock(&cpu_buffer->reader_lock); 2524 spin_unlock(&cpu_buffer->reader_lock);
2524 local_irq_restore(flags); 2525 local_irq_restore(flags);
@@ -2590,12 +2591,9 @@ ring_buffer_consume(struct ring_buffer *buffer, int cpu, u64 *ts)
2590 spin_lock(&cpu_buffer->reader_lock); 2591 spin_lock(&cpu_buffer->reader_lock);
2591 2592
2592 event = rb_buffer_peek(buffer, cpu, ts); 2593 event = rb_buffer_peek(buffer, cpu, ts);
2593 if (!event) 2594 if (event)
2594 goto out_unlock; 2595 rb_advance_reader(cpu_buffer);
2595
2596 rb_advance_reader(cpu_buffer);
2597 2596
2598 out_unlock:
2599 if (dolock) 2597 if (dolock)
2600 spin_unlock(&cpu_buffer->reader_lock); 2598 spin_unlock(&cpu_buffer->reader_lock);
2601 local_irq_restore(flags); 2599 local_irq_restore(flags);