From: Kris Van Hees Date: Thu, 8 Sep 2011 15:13:26 +0000 (-0400) Subject: dtrace: add dtrace_gethrtime() and fix walltimestamp. X-Git-Tag: v4.1.12-92~313^2~171 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=64ef4e504fd8cb46d3abe2e6c25df69b11379d5e;p=users%2Fjedix%2Flinux-maple.git dtrace: add dtrace_gethrtime() and fix walltimestamp. The walltimestamp is required to be the time in nanoseconds since the epoch, not the time in nanoseconds since boot or since dtrace invocation. So we no longer need dtrace_mstate.dtms_walltimestamp, nor the flag used to track its updating: but we *do* need a new way to get the time that is safe for non-GPL use. This fixes test/act/time.d (which is the only test that checks if walltimestamp not only exists but returns the right value). Orabug: 18376038 Signed-off-by: Kris Van Hees Signed-off-by: Nick Alcock Acked-by: Jerry Snitselaar --- diff --git a/kernel/dtrace/dtrace_os.c b/kernel/dtrace/dtrace_os.c index fdb36a9deb1c..53184b983c35 100644 --- a/kernel/dtrace/dtrace_os.c +++ b/kernel/dtrace/dtrace_os.c @@ -13,6 +13,30 @@ #include "cyclic.h" #include "systrace.h" +/* + * Return a high resolution timer value that is guaranteed to always increase. + */ +ktime_t dtrace_gethrtime(void) +{ + struct timespec ts; + + getrawmonotonic(&ts); + return timespec_to_ktime(ts); +} +EXPORT_SYMBOL(dtrace_gethrtime); + +/* + * Return the current wall-clock time, in nanoseconds since the epoch. + */ +ktime_t dtrace_getwalltime(void) +{ + struct timespec ts; + + getnstimeofday(&ts); + return timespec_to_ktime(ts); +} +EXPORT_SYMBOL(dtrace_getwalltime); + /* * Very basic implementation of cyclics, merely enough to support dtrace. */