[RFC PATCH 17/22 -v2] Add timestamps to tracer

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: LKML <linux-kernel@...>
Cc: Ingo Molnar <mingo@...>, Linus Torvalds <torvalds@...>, Andrew Morton <akpm@...>, Peter Zijlstra <a.p.zijlstra@...>, Christoph Hellwig <hch@...>, Mathieu Desnoyers <mathieu.desnoyers@...>, Gregory Haskins <ghaskins@...>, Arnaldo Carvalho de Melo <acme@...>, Thomas Gleixner <tglx@...>, Tim Bird <tim.bird@...>, Sam Ravnborg <sam@...>, Frank Ch. Eigler <fche@...>, Steven Rostedt <srostedt@...>
Date: Wednesday, January 9, 2008 - 7:29 pm

Add timestamps to trace entries.

Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
 lib/tracing/tracer.c |   16 ++++++++++++++++
 lib/tracing/tracer.h |    1 +
 2 files changed, 17 insertions(+)

Index: linux-compile-i386.git/lib/tracing/tracer.c
===================================================================
--- linux-compile-i386.git.orig/lib/tracing/tracer.c	2008-01-09 14:16:05.000000000 -0500
+++ linux-compile-i386.git/lib/tracing/tracer.c	2008-01-09 15:17:27.000000000 -0500
@@ -19,12 +19,18 @@
 #include <linux/percpu.h>
 #include <linux/debugfs.h>
 #include <linux/kallsyms.h>
+#include <linux/clocksource.h>
 #include <linux/uaccess.h>
 #include <linux/mcount.h>
 
 #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);
 
@@ -57,6 +63,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);
 }
 
@@ -240,6 +247,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-i386.git/lib/tracing/tracer.h
===================================================================
--- linux-compile-i386.git.orig/lib/tracing/tracer.h	2008-01-09 14:16:05.000000000 -0500
+++ linux-compile-i386.git/lib/tracing/tracer.h	2008-01-09 15:17:27.000000000 -0500
@@ -5,6 +5,7 @@
 #include <linux/sched.h>
 
 struct mctracer_entry {
+	unsigned long long t;
 	unsigned long idx;
 	unsigned long ip;
 	unsigned long parent_ip;

-- 
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[RFC PATCH 17/22 -v2] Add timestamps to tracer, Steven Rostedt, (Wed Jan 9, 7:29 pm)