aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2009-04-29 00:23:13 -0400
committerSteven Rostedt <rostedt@goodmis.org>2009-04-29 00:23:13 -0400
commit93459c6cb9816c52200993d29dd18cea1daee335 (patch)
tree9ee6a4e9fda5d77d0d05b7855cd2de59fb62d8a0 /kernel/trace
parent5beae6efd1004b44c3e257dc96087978e4c763c1 (diff)
tracing: only add splice page if entries exist
The splice code allocates a page even when the ring buffer is empty. It detects the ring buffer being empty when it it fails to copy anything from the ring buffer into the page. This patch adds a check to see if there is anything in the ring buffer before allocating a page. Thanks to logdev for letting me trace the tracer to find this. [ Impact: speed up due to removing unnecessary allocation ] Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace')
-rw-r--r--kernel/trace/trace.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 9058240c85ca..0aeb3b93414e 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -3508,7 +3508,7 @@ tracing_buffers_splice_read(struct file *file, loff_t *ppos,
3508 .spd_release = buffer_spd_release, 3508 .spd_release = buffer_spd_release,
3509 }; 3509 };
3510 struct buffer_ref *ref; 3510 struct buffer_ref *ref;
3511 int size, i; 3511 int entries, size, i;
3512 size_t ret; 3512 size_t ret;
3513 3513
3514 if (*ppos & (PAGE_SIZE - 1)) { 3514 if (*ppos & (PAGE_SIZE - 1)) {
@@ -3523,7 +3523,9 @@ tracing_buffers_splice_read(struct file *file, loff_t *ppos,
3523 len &= PAGE_MASK; 3523 len &= PAGE_MASK;
3524 } 3524 }
3525 3525
3526 for (i = 0; i < PIPE_BUFFERS && len; i++, len -= PAGE_SIZE) { 3526 entries = ring_buffer_entries_cpu(info->tr->buffer, info->cpu);
3527
3528 for (i = 0; i < PIPE_BUFFERS && len && entries; i++, len -= PAGE_SIZE) {
3527 struct page *page; 3529 struct page *page;
3528 int r; 3530 int r;
3529 3531
@@ -3564,6 +3566,8 @@ tracing_buffers_splice_read(struct file *file, loff_t *ppos,
3564 spd.partial[i].private = (unsigned long)ref; 3566 spd.partial[i].private = (unsigned long)ref;
3565 spd.nr_pages++; 3567 spd.nr_pages++;
3566 *ppos += PAGE_SIZE; 3568 *ppos += PAGE_SIZE;
3569
3570 entries = ring_buffer_entries_cpu(info->tr->buffer, info->cpu);
3567 } 3571 }
3568 3572
3569 spd.nr_pages = i; 3573 spd.nr_pages = i;