From: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
To: mingo@elte.hu
Cc: LKML <linux-kernel@vger.kernel.org>,
kosaki.motohiro@jp.fujitsu.com, Zhaolei <zhaolei@cn.fujitsu.com>,
Steven Rostedt <rostedt@goodmis.org>,
Thomas Gleixner <tglx@linutronix.de>,
fweisbec@gmail.com,
Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>,
Tom Zanussi <tzanussi@gmail.com>
Subject: [PATCH] ftrace: add tracepoint for xtime
Date: Wed, 27 May 2009 17:10:37 +0800 [thread overview]
Message-ID: <4A1D038D.40704@cn.fujitsu.com> (raw)
This patch can trace current xtime and wall_to_monotonic. Then user can
use ctime() to convert them to wall time which is easier to be understood,
especially for flight-recorder which need to get trace event from a kernel
dump file.
Example of ftrace output:
<idle>-0 [000] 20118.489849: gtod_update_xtime: xtime=1243265589.999999824 wall_to_monotonic=3051713268.744158739
<...>-4020 [001] 20118.489855: sys_open(filename: bf9e66e0, flags: 98800, mode: bf9e66e0)
<...>-4020 [001] 20118.489873: sys_open -> 0xffffffec
ctime(1243265590) = date:Mon May 25 11:33:10 2009
So we can realize the task with pid 4020 open a file at
Mon May 25 11:33:10 2009
Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
---
include/trace/events/xtime.h | 38 ++++++++++++++++++++++++++++++++++++++
kernel/time/ntp.c | 2 ++
kernel/time/timekeeping.c | 5 +++++
3 files changed, 45 insertions(+), 0 deletions(-)
create mode 100644 include/trace/events/xtime.h
diff --git a/include/trace/events/xtime.h b/include/trace/events/xtime.h
new file mode 100644
index 0000000..f07bb64
--- /dev/null
+++ b/include/trace/events/xtime.h
@@ -0,0 +1,38 @@
+#if !defined(_TRACE_XTIME_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_XTIME_H
+
+#include <linux/time.h>
+#include <linux/tracepoint.h>
+
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM xtime
+
+TRACE_EVENT(gtod_update_xtime,
+
+ TP_PROTO(struct timespec *xtime, struct timespec *wall_to_monotonic),
+
+ TP_ARGS(xtime, wall_to_monotonic),
+
+ TP_STRUCT__entry(
+ __field( long, xtime_sec )
+ __field( long, xtime_nsec )
+ __field( long, wall_to_monotonic_sec )
+ __field( long, wall_to_monotonic_nsec )
+ ),
+
+ TP_fast_assign(
+ __entry->xtime_sec = xtime->tv_sec;
+ __entry->xtime_nsec = xtime->tv_nsec;
+ __entry->wall_to_monotonic_sec = wall_to_monotonic->tv_sec;
+ __entry->wall_to_monotonic_nsec = wall_to_monotonic->tv_nsec;
+ ),
+
+ TP_printk("xtime=%ld.%09ld wall_to_monotonic=%ld.%09ld",
+ __entry->xtime_sec, __entry->xtime_nsec,
+ __entry->wall_to_monotonic_sec, __entry->wall_to_monotonic_nsec)
+);
+
+#endif /* _TRACE_XTIME_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
index 7fc6437..33db762 100644
--- a/kernel/time/ntp.c
+++ b/kernel/time/ntp.c
@@ -14,6 +14,7 @@
#include <linux/timex.h>
#include <linux/time.h>
#include <linux/mm.h>
+#include <trace/events/xtime.h>
/*
* NTP timekeeping variables:
@@ -220,6 +221,7 @@ static enum hrtimer_restart ntp_leap_second(struct hrtimer *timer)
break;
}
update_vsyscall(&xtime, clock);
+ trace_gtod_update_xtime(&xtime, &wall_to_monotonic);
write_sequnlock(&xtime_lock);
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index e8c77d9..798f93e 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -19,6 +19,9 @@
#include <linux/time.h>
#include <linux/tick.h>
+#define CREATE_TRACE_POINTS
+#include <trace/events/xtime.h>
+
/*
* This read-write spinlock protects us from races in SMP while
@@ -171,6 +174,7 @@ int do_settimeofday(struct timespec *tv)
ntp_clear();
update_vsyscall(&xtime, clock);
+ trace_gtod_update_xtime(&xtime, &wall_to_monotonic);
write_sequnlock_irqrestore(&xtime_lock, flags);
@@ -568,6 +572,7 @@ void update_wall_time(void)
/* check to see if there is a new clocksource to use */
change_clocksource();
update_vsyscall(&xtime, clock);
+ trace_gtod_update_xtime(&xtime, &wall_to_monotonic);
}
/**
--
1.6.1.2
reply other threads:[~2009-05-27 9:10 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4A1D038D.40704@cn.fujitsu.com \
--to=xiaoguangrong@cn.fujitsu.com \
--cc=fweisbec@gmail.com \
--cc=kosaki.motohiro@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@polymtl.ca \
--cc=mingo@elte.hu \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=tzanussi@gmail.com \
--cc=zhaolei@cn.fujitsu.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.