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>,
Eduard - Gabriel Munteanu <eduard.munteanu@linux360.ro>,
Pekka Enberg <penberg@cs.helsinki.fi>,
Steven Rostedt <srostedt@redhat.com>
Subject: [PATCH 3/3] tracing: clean up splice code
Date: Mon, 09 Feb 2009 12:28:33 -0500 [thread overview]
Message-ID: <20090209172956.970104543@goodmis.org> (raw)
In-Reply-To: 20090209172830.087244662@goodmis.org
[-- Attachment #1: 0003-tracing-clean-up-splice-code.patch --]
[-- Type: text/plain, Size: 3956 bytes --]
From: Steven Rostedt <srostedt@redhat.com>
Ingo Molnar suggested a series of clean ups for the splice code.
This patch implements those suggestions.
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
kernel/trace/trace.c | 96 ++++++++++++++++++++++++++++---------------------
1 files changed, 55 insertions(+), 41 deletions(-)
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 11fde0a..d898212 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -2537,15 +2537,49 @@ static void tracing_spd_release_pipe(struct splice_pipe_desc *spd,
}
static struct pipe_buf_operations tracing_pipe_buf_ops = {
- .can_merge = 0,
- .map = generic_pipe_buf_map,
- .unmap = generic_pipe_buf_unmap,
- .confirm = generic_pipe_buf_confirm,
- .release = tracing_pipe_buf_release,
- .steal = generic_pipe_buf_steal,
- .get = generic_pipe_buf_get,
+ .can_merge = 0,
+ .map = generic_pipe_buf_map,
+ .unmap = generic_pipe_buf_unmap,
+ .confirm = generic_pipe_buf_confirm,
+ .release = tracing_pipe_buf_release,
+ .steal = generic_pipe_buf_steal,
+ .get = generic_pipe_buf_get,
};
+static size_t
+tracing_fill_pipe_page(struct page *pages, size_t rem,
+ struct trace_iterator *iter)
+{
+ size_t count;
+ int ret;
+
+ /* Seq buffer is page-sized, exactly what we need. */
+ for (;;) {
+ count = iter->seq.len;
+ ret = print_trace_line(iter);
+ count = iter->seq.len - count;
+ if (rem < count) {
+ rem = 0;
+ iter->seq.len -= count;
+ break;
+ }
+ if (ret == TRACE_TYPE_PARTIAL_LINE) {
+ iter->seq.len -= count;
+ break;
+ }
+
+ trace_consume(iter);
+ rem -= count;
+ if (!find_next_entry_inc(iter)) {
+ rem = 0;
+ iter->ent = NULL;
+ break;
+ }
+ }
+
+ return rem;
+}
+
static ssize_t tracing_splice_read_pipe(struct file *filp,
loff_t *ppos,
struct pipe_inode_info *pipe,
@@ -2556,15 +2590,15 @@ static ssize_t tracing_splice_read_pipe(struct file *filp,
struct partial_page partial[PIPE_BUFFERS];
struct trace_iterator *iter = filp->private_data;
struct splice_pipe_desc spd = {
- .pages = pages,
- .partial = partial,
- .nr_pages = 0, /* This gets updated below. */
- .flags = flags,
- .ops = &tracing_pipe_buf_ops,
- .spd_release = tracing_spd_release_pipe,
+ .pages = pages,
+ .partial = partial,
+ .nr_pages = 0, /* This gets updated below. */
+ .flags = flags,
+ .ops = &tracing_pipe_buf_ops,
+ .spd_release = tracing_spd_release_pipe,
};
ssize_t ret;
- size_t count, rem;
+ size_t rem;
unsigned int i;
mutex_lock(&trace_types_lock);
@@ -2573,45 +2607,25 @@ static ssize_t tracing_splice_read_pipe(struct file *filp,
ret = iter->trace->splice_read(iter, filp,
ppos, pipe, len, flags);
if (ret)
- goto out;
+ goto out_err;
}
ret = tracing_wait_pipe(filp);
if (ret <= 0)
- goto out;
+ goto out_err;
if (!iter->ent && !find_next_entry_inc(iter)) {
ret = -EFAULT;
- goto out;
+ goto out_err;
}
/* Fill as many pages as possible. */
for (i = 0, rem = len; i < PIPE_BUFFERS && rem; i++) {
pages[i] = alloc_page(GFP_KERNEL);
+ if (!pages[i])
+ break;
- /* Seq buffer is page-sized, exactly what we need. */
- for (;;) {
- count = iter->seq.len;
- ret = print_trace_line(iter);
- count = iter->seq.len - count;
- if (rem < count) {
- rem = 0;
- iter->seq.len -= count;
- break;
- }
- if (ret == TRACE_TYPE_PARTIAL_LINE) {
- iter->seq.len -= count;
- break;
- }
-
- trace_consume(iter);
- rem -= count;
- if (!find_next_entry_inc(iter)) {
- rem = 0;
- iter->ent = NULL;
- break;
- }
- }
+ rem = tracing_fill_pipe_page(pages[i], rem, iter);
/* Copy the data into the page, so we can start over. */
ret = trace_seq_to_buffer(&iter->seq,
@@ -2633,7 +2647,7 @@ static ssize_t tracing_splice_read_pipe(struct file *filp,
return splice_to_pipe(pipe, &spd);
-out:
+out_err:
mutex_unlock(&trace_types_lock);
return ret;
--
1.5.6.5
--
next prev parent reply other threads:[~2009-02-09 17:30 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-09 17:28 [PATCH 0/3] git pull request for tip/tracing/ftrace Steven Rostedt
2009-02-09 17:28 ` [PATCH 1/3] tracing: splice support for tracing_pipe Steven Rostedt
2009-02-09 17:28 ` [PATCH 2/3] tracing: Move pipe waiting code out of tracing_read_pipe() Steven Rostedt
2009-02-09 17:33 ` Frederic Weisbecker
2009-02-09 17:28 ` Steven Rostedt [this message]
2009-02-09 18:25 ` [PATCH 3/3] tracing: clean up splice code Eduard - Gabriel Munteanu
2009-02-09 18:26 ` Pekka Enberg
2009-02-09 18:37 ` Eduard - Gabriel Munteanu
2009-02-09 18:43 ` Steven Rostedt
2009-02-10 13:00 ` [PATCH 0/3] git pull request for tip/tracing/ftrace Ingo Molnar
2009-02-10 14:08 ` Steven Rostedt
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=20090209172956.970104543@goodmis.org \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=eduard.munteanu@linux360.ro \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=penberg@cs.helsinki.fi \
--cc=srostedt@redhat.com \
/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