From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758588AbYAOU6o (ORCPT ); Tue, 15 Jan 2008 15:58:44 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1757454AbYAOUu6 (ORCPT ); Tue, 15 Jan 2008 15:50:58 -0500 Received: from ms-smtp-05.nyroc.rr.com ([24.24.2.59]:65115 "EHLO ms-smtp-05.nyroc.rr.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756447AbYAOUuh (ORCPT ); Tue, 15 Jan 2008 15:50:37 -0500 Message-Id: <20080115205025.192359753@goodmis.org> References: <20080115204907.838227723@goodmis.org> User-Agent: quilt/0.46-1 Date: Tue, 15 Jan 2008 15:49:27 -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" , Jan Kiszka , Steven Rostedt Subject: [RFC PATCH 20/30 v3] Add timestamps to tracer Content-Disposition: inline; filename=mcount-tracer-timestamp.patch Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add timestamps to trace entries. Signed-off-by: Steven Rostedt --- lib/tracing/tracer.c | 16 ++++++++++++++++ lib/tracing/tracer.h | 1 + 2 files changed, 17 insertions(+) Index: linux-compile.git/lib/tracing/tracer.c =================================================================== --- linux-compile.git.orig/lib/tracing/tracer.c 2008-01-14 13:14:13.000000000 -0500 +++ linux-compile.git/lib/tracing/tracer.c 2008-01-14 14:57:41.000000000 -0500 @@ -19,12 +19,18 @@ #include #include #include +#include #include #include #include "tracer.h" #include "tracer_interface.h" +static inline notrace cycle_t now(void) +{ + return get_monotonic_cycles(); +} + static struct mctracer_trace mctracer_trace; static DEFINE_PER_CPU(struct mctracer_trace_cpu, mctracer_trace_cpu); static int trace_enabled __read_mostly; @@ -58,6 +64,7 @@ mctracer_add_trace_entry(struct mctracer entry->ip = ip; entry->parent_ip = parent_ip; entry->pid = tsk->pid; + entry->t = now(); memcpy(entry->comm, tsk->comm, TASK_COMM_LEN); } @@ -250,6 +257,15 @@ static int s_show(struct seq_file *m, vo if (iter->ent == NULL) { seq_printf(m, "mctracer:\n"); } else { + unsigned long long t; + unsigned long usec_rem; + unsigned long secs; + + t = cycles_to_usecs(iter->ent->t); + usec_rem = do_div(t, 1000000ULL); + secs = (unsigned long)t; + + seq_printf(m, "[%5lu.%06lu] ", secs, usec_rem); seq_printf(m, "CPU %d: ", iter->cpu); seq_printf(m, "%s:%d ", iter->ent->comm, iter->ent->pid); seq_print_ip_sym(m, iter->ent->ip, sym_only); Index: linux-compile.git/lib/tracing/tracer.h =================================================================== --- linux-compile.git.orig/lib/tracing/tracer.h 2008-01-14 13:14:13.000000000 -0500 +++ linux-compile.git/lib/tracing/tracer.h 2008-01-14 14:57:41.000000000 -0500 @@ -5,6 +5,7 @@ #include struct mctracer_entry { + unsigned long long t; unsigned long idx; unsigned long ip; unsigned long parent_ip; --