lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1363626105-2107-1-git-send-email-dsahern@gmail.com>
Date:	Mon, 18 Mar 2013 11:01:45 -0600
From:	David Ahern <dsahern@...il.com>
To:	linux-kernel@...r.kernel.org, tglx@...utronix.de,
	johnstul@...ibm.com
Cc:	David Ahern <dsahern@...il.com>
Subject: [PATCH] timekeeping: Add tracepoints for xtime changes

One component of tracking perf_clock timestamps to time-of-day is
updates to xtime by a user or ntpd. To that end this patch adds
tracepoints to the timekeeping code as suggested by Thomas:
https://lkml.org/lkml/2011/3/2/186

Signed-off-by: David Ahern <dsahern@...il.com>
Cc: Thomas Gleixner <tglx@...utronix.de>
Cc: John Stultz <johnstul@...ibm.com>
---
 include/trace/events/timekeeping.h |   51 ++++++++++++++++++++++++++++++++++++
 kernel/time/timekeeping.c          |   10 +++++++
 2 files changed, 61 insertions(+)
 create mode 100644 include/trace/events/timekeeping.h

diff --git a/include/trace/events/timekeeping.h b/include/trace/events/timekeeping.h
new file mode 100644
index 0000000..ff7a631
--- /dev/null
+++ b/include/trace/events/timekeeping.h
@@ -0,0 +1,51 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM timekeeping
+
+#if !defined(_TRACE_TIMEKEEP_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_TIMEKEEP_H
+
+#include <linux/tracepoint.h>
+#include <linux/time.h>
+
+DECLARE_EVENT_CLASS(xtime_template,
+
+	TP_PROTO(u64 sec, u64 nsec),
+
+	TP_ARGS(sec, nsec),
+
+	TP_STRUCT__entry(
+		__field( u64,	sec)
+		__field( u64,	nsec)
+	),
+
+	TP_fast_assign(
+		__entry->sec  = sec;
+		__entry->nsec = nsec;
+	),
+
+	TP_printk("sec=%Lu nsec=%Lu", __entry->sec, __entry->nsec)
+);
+
+DEFINE_EVENT(xtime_template, do_settimeofday,
+	TP_PROTO(u64 sec, u64 nsec),
+	TP_ARGS(sec, nsec));
+
+DEFINE_EVENT(xtime_template, timekeeping_inject_offset,
+	TP_PROTO(u64 sec, u64 nsec),
+	TP_ARGS(sec, nsec));
+
+DEFINE_EVENT(xtime_template, timekeeping_inject_sleeptime,
+	TP_PROTO(u64 sec, u64 nsec),
+	TP_ARGS(sec, nsec));
+
+DEFINE_EVENT(xtime_template, timekeeping_resume,
+	TP_PROTO(u64 sec, u64 nsec),
+	TP_ARGS(sec, nsec));
+
+DEFINE_EVENT(xtime_template, change_clocksource,
+	TP_PROTO(u64 sec, u64 nsec),
+	TP_ARGS(sec, nsec));
+#endif /*  _TRACE_TIMEKEEP_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 9a0bc98..097114c 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -23,6 +23,8 @@
 #include <linux/stop_machine.h>
 #include <linux/pvclock_gtod.h>
 
+#define CREATE_TRACE_POINTS
+#include <trace/events/timekeeping.h>
 
 static struct timekeeper timekeeper;
 
@@ -462,6 +464,8 @@ int do_settimeofday(const struct timespec *tv)
 
 	timekeeping_update(tk, true);
 
+	trace_do_settimeofday(tk->xtime_sec, tk->xtime_nsec);
+
 	write_sequnlock_irqrestore(&tk->lock, flags);
 
 	/* signal hrtimers about time change */
@@ -504,6 +508,8 @@ int timekeeping_inject_offset(struct timespec *ts)
 error: /* even if we error out, we forwarded the time, so call update */
 	timekeeping_update(tk, true);
 
+	trace_timekeeping_inject_offset(tk->xtime_sec, tk->xtime_nsec);
+
 	write_sequnlock_irqrestore(&tk->lock, flags);
 
 	/* signal hrtimers about time change */
@@ -536,6 +542,7 @@ static int change_clocksource(void *data)
 			old->disable(old);
 	}
 	timekeeping_update(tk, true);
+	trace_change_clocksource(tk->xtime_sec, tk->xtime_nsec);
 
 	write_sequnlock_irqrestore(&tk->lock, flags);
 
@@ -772,6 +779,8 @@ void timekeeping_inject_sleeptime(struct timespec *delta)
 
 	timekeeping_update(tk, true);
 
+	trace_timekeeping_inject_sleeptime(tk->xtime_sec, tk->xtime_nsec);
+
 	write_sequnlock_irqrestore(&tk->lock, flags);
 
 	/* signal hrtimers about time change */
@@ -807,6 +816,7 @@ static void timekeeping_resume(void)
 	tk->ntp_error = 0;
 	timekeeping_suspended = 0;
 	timekeeping_update(tk, false);
+	trace_timekeeping_resume(tk->xtime_sec, tk->xtime_nsec);
 	write_sequnlock_irqrestore(&tk->lock, flags);
 
 	touch_softlockup_watchdog();
-- 
1.7.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ