From: Steven Rostedt 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. Cc: Lai Jiangshan Signed-off-by: Steven Rostedt --- kernel/trace/trace.c | 32 +++++--------------------------- 1 files changed, 5 insertions(+), 27 deletions(-) diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index df25c4f..0ee4e0e 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -468,25 +468,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 @@ -3240,21 +3221,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_event_read_unlock(); mutex_unlock(&iter->mutex); -- 1.6.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/