From: Lai Jiangshan <laijs@cn.fujitsu.com>
To: Steven Rostedt <rostedt@goodmis.org>,
linux-kernel@vger.kernel.org, Ingo Molnar <mingo@elte.hu>,
Andrew Morton <akpm@linux-foundation.org>,
Frederic Weisbecker <fweisbec@gmail.com>
Subject: [PATCH 6/6] tracing: Write directly into splice page for trace_pipe
Date: Tue, 19 Jan 2010 15:34:30 +0800 [thread overview]
Message-ID: <4B556086.7000909@cn.fujitsu.com> (raw)
From: Steven Rostedt <srostedt@redhat.com>
Now that the trace_seq has a separate buffer space, we can use this
feature to write directly into the splice page, instead of writing
to the trace_seq buffer and then copying it. This has shown almost
a 4% improvement in reading trace_pipe via splice:
Average timing of reading 10megs from trace_pipe before patch:
real 0m1.619s
user 0m0.002s
sys 0m1.596s
After patch:
real 0m1.561s
user 0m0.002s
sys 0m1.535s
These were the average of five runs of reading 10megs.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
---
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 74ad344..0030d4b 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -544,25 +544,6 @@ ssize_t trace_seq_to_user(struct trace_seq *s, char __user *ubuf, size_t cnt)
return cnt;
}
-static ssize_t trace_seq_to_buffer(struct trace_seq *s, void *buf, size_t cnt)
-{
- int len;
- void *ret;
-
- if (s->len <= s->readpos)
- return -EBUSY;
-
- len = s->len - s->readpos;
- if (cnt > len)
- cnt = len;
- ret = memcpy(buf, s->buffer + s->readpos, cnt);
- if (!ret)
- return -EFAULT;
-
- s->readpos += cnt;
- return cnt;
-}
-
/*
* ftrace_max_lock is used to protect the swapping of buffers
* when taking a max snapshot. The buffers themselves are
@@ -3280,21 +3261,18 @@ static ssize_t tracing_splice_read_pipe(struct file *filp,
if (!pages[i])
break;
- rem = tracing_fill_pipe_page(rem, iter);
+ trace_seq_init(&iter->seq, page_address(pages[i]), PAGE_SIZE);
- /* Copy the data into the page, so we can start over. */
- ret = trace_seq_to_buffer(&iter->seq,
- page_address(pages[i]),
- iter->seq.len);
- if (ret < 0) {
+ rem = tracing_fill_pipe_page(rem, iter);
+ if (!iter->seq.len) {
__free_page(pages[i]);
break;
}
+
partial[i].offset = 0;
partial[i].len = iter->seq.len;
-
- trace_seq_reset(&iter->seq);
}
+ trace_seq_init(&iter->seq, iter->buffer, FTRACE_SEQ_BUFSIZE);
trace_access_unlock(iter->cpu_file);
trace_event_read_unlock();
reply other threads:[~2010-01-19 7:36 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=4B556086.7000909@cn.fujitsu.com \
--to=laijs@cn.fujitsu.com \
--cc=akpm@linux-foundation.org \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=rostedt@goodmis.org \
/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