From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758163AbYAIXhx (ORCPT ); Wed, 9 Jan 2008 18:37:53 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755991AbYAIXbQ (ORCPT ); Wed, 9 Jan 2008 18:31:16 -0500 Received: from ms-smtp-01.nyroc.rr.com ([24.24.2.55]:53984 "EHLO ms-smtp-01.nyroc.rr.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756009AbYAIXax (ORCPT ); Wed, 9 Jan 2008 18:30:53 -0500 Message-Id: <20080109233045.251234302@goodmis.org> References: <20080109232914.676624725@goodmis.org> User-Agent: quilt/0.46-1 Date: Wed, 09 Jan 2008 18:29:33 -0500 From: Steven Rostedt To: LKML Cc: Ingo Molnar , Linus Torvalds , Andrew Morton , Peter Zijlstra , Christoph Hellwig , Mathieu Desnoyers , Gregory Haskins , Arnaldo Carvalho de Melo , Thomas Gleixner , Tim Bird , Sam Ravnborg , "Frank Ch. Eigler" , Steven Rostedt Subject: [RFC PATCH 19/22 -v2] speed up the output of the tracer Content-Disposition: inline; filename=mcount-tracer-speed-output.patch Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- lib/tracing/tracer.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) Index: linux-compile-i386.git/lib/tracing/tracer.c =================================================================== --- linux-compile-i386.git.orig/lib/tracing/tracer.c 2008-01-09 14:37:13.000000000 -0500 +++ linux-compile-i386.git/lib/tracing/tracer.c 2008-01-09 15:17:24.000000000 -0500 @@ -105,6 +105,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; @@ -176,6 +177,8 @@ static void *s_next(struct seq_file *m, while (ent && iter->idx < i) ent = find_next_entry(iter); + iter->pos = *pos; + return ent; } @@ -186,19 +189,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) clear_mcount_function(); - 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; } @@ -286,6 +295,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); --