public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@elte.hu>,
	Andrew Morton <akpm@linux-foundation.org>,
	Frederic Weisbecker <fweisbec@gmail.com>
Subject: [PATCH 3/5] tracing: only add splice page if entries exist
Date: Wed, 29 Apr 2009 00:48:17 -0400	[thread overview]
Message-ID: <20090429045906.295559520@goodmis.org> (raw)
In-Reply-To: 20090429044814.138790038@goodmis.org

[-- Attachment #1: 0003-tracing-only-add-splice-page-if-entries-exist.patch --]
[-- Type: text/plain, Size: 1608 bytes --]

From: Steven Rostedt <srostedt@redhat.com>

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>
---
 kernel/trace/trace.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 9058240..0aeb3b9 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,
 		.spd_release	= buffer_spd_release,
 	};
 	struct buffer_ref *ref;
-	int size, i;
+	int entries, size, i;
 	size_t ret;
 
 	if (*ppos & (PAGE_SIZE - 1)) {
@@ -3523,7 +3523,9 @@ tracing_buffers_splice_read(struct file *file, loff_t *ppos,
 		len &= PAGE_MASK;
 	}
 
-	for (i = 0; i < PIPE_BUFFERS && len; i++, len -= PAGE_SIZE) {
+	entries = ring_buffer_entries_cpu(info->tr->buffer, info->cpu);
+
+	for (i = 0; i < PIPE_BUFFERS && len && entries; i++, len -= PAGE_SIZE) {
 		struct page *page;
 		int r;
 
@@ -3564,6 +3566,8 @@ tracing_buffers_splice_read(struct file *file, loff_t *ppos,
 		spd.partial[i].private = (unsigned long)ref;
 		spd.nr_pages++;
 		*ppos += PAGE_SIZE;
+
+		entries = ring_buffer_entries_cpu(info->tr->buffer, info->cpu);
 	}
 
 	spd.nr_pages = i;
-- 
1.6.2.1

-- 

  parent reply	other threads:[~2009-04-29  5:00 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-29  4:48 [PATCH 0/5] [GIT PULL] tracing/splice/ringbuffer: updates for tip Steven Rostedt
2009-04-29  4:48 ` [PATCH 1/5] tracing: convert ftrace_dump spinlocks to raw Steven Rostedt
2009-04-29  5:07   ` Andrew Morton
2009-04-29  5:55     ` Ingo Molnar
2009-04-29  4:48 ` [PATCH 2/5] tracing: fix ref count in splice pages Steven Rostedt
2009-04-29  4:48 ` Steven Rostedt [this message]
2009-04-29  4:48 ` [PATCH 4/5] tracing: have splice only copy full pages Steven Rostedt
2009-04-29  4:48 ` [PATCH 5/5] ring-buffer: fix printk output Steven Rostedt
2009-04-29  5:20   ` Andrew Morton
2009-04-29  5:43     ` Ingo Molnar
2009-04-29  5:55       ` Andrew Morton
2009-04-29  6:09         ` Ingo Molnar
2009-04-29  6:20           ` Andrew Morton
2009-04-29  7:22             ` Ingo Molnar
2009-04-29  7:41               ` Andrew Morton
2009-04-29  9:56                 ` Ingo Molnar
2009-04-29 15:09                   ` Andrew Morton
2009-04-29 19:45                     ` Ingo Molnar
2009-04-29 19:52                       ` Andrew Morton
2009-04-29 20:11                         ` Ingo Molnar
2009-04-29 16:19             ` Valdis.Kletnieks
2009-04-29 20:15               ` Ingo Molnar
2009-04-29  6:03 ` [PATCH 0/5] [GIT PULL] tracing/splice/ringbuffer: updates for tip Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090429045906.295559520@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox