[RFC PATCH 22/30 v3] speed up the output of the tracer

Steven Rostedt
2008-01-15T20:50:46Z

[-- Attachment #1: mcount-tracer-speed-output.patch --]
[-- Type: text/plain, Size: 1901 bytes --]

The current method of printing out the trace is on every
read, do a linear search for the next entry to print.
This patch remembers the next entry to look at in the
iterator, and if the next read is sequential, it can
start reading from the next location.

Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
lib/tracing/tracer.c | 28 +++++++++++++++++++---------
1 file changed, 19 insertions(+), 9 deletions(-)

Index: linux-compile.git/lib/tracing/tracer.c
===================================================================
--- linux-compile.git.orig/lib/tracing/tracer.c 2008-01-14 13:14:14.000000000 -0500
+++ linux-compile.git/lib/tracing/tracer.c 2008-01-14 14:57:38.000000000 -0500
@@ -115,6 +115,7 @@ enum trace_iterator {
struct mctracer_iterator {
struct mctracer_trace *tr;
struct mctracer_entry *ent;
+ loff_t pos;
unsigned long next_idx[NR_CPUS];
int cpu;
int idx;
@@ -186,6 +187,8 @@ static void *s_next(struct seq_file *m,
while (ent && iter->idx < i)
ent = find_next_entry(iter);

+ iter->pos = *pos;
+
return ent;
}

@@ -196,19 +199,25 @@ static void *s_start(struct seq_file *m,
loff_t l = 0;
int i;

- iter->ent = NULL;
- iter->cpu = 0;
- iter->idx = -1;
-
- for (i = 0; i < NR_CPUS; i++)
- iter->next_idx[i] = 0;
-
/* stop the trace while dumping */
if (iter->tr->ctrl)
trace_enabled = 0;

- for (p = iter; p && l < *pos; p = s_next(m, p, &l))
- ;
+ if (*pos != iter->pos) {
+ iter->ent = NULL;
+ iter->cpu = 0;
+ iter->idx = -1;
+
+ for (i = 0; i < NR_CPUS; i++)
+ iter->next_idx[i] = 0;
+
+ for (p = iter; p && l < *pos; p = s_next(m, p, &l))
+ ;
+
+ } else {
+ l = *pos;
+ p = s_next(m, p, &l);
+ }

return p;
}
@@ -296,6 +305,7 @@ static int mctrace_open(struct inode *in
return -ENOMEM;

iter->tr = &mctracer_trace;
+ iter->pos = -1;

/* TODO stop tracer */
ret = seq_open(file, &mctrace_seq_ops);

--