@@ -62,6 +62,8 @@
#include <linux/types.h>
#include <linux/param.h>
+extern u64 ktime_read_raw_clock(void);
+
#include <asm/timex.h>
#ifndef random_get_entropy
@@ -939,6 +939,14 @@ ktime_t ktime_get_raw(void)
}
EXPORT_SYMBOL_GPL(ktime_get_raw);
+/**
+ * ktime_read_raw_clock - Returns the raw clock source value
+ */
+u64 ktime_read_raw_clock(void)
+{
+ return tk_clock_read(&tk_core.timekeeper.tkr_mono);
+}
+
/**
* ktime_get_ts64 - get the monotonic clock in timespec64 format
* @ts: pointer to timespec variable
This provides access to whichever time source has the highest frequency, which is useful for gathering entropy on platforms without available cycle counters. It's not necessarily as good as being able to quickly access a cycle counter that the CPU has, but it's still something, even when it falls back to being jiffies-based. It's defined in linux/timex.h rather than linux/timekeeping.h, because the latter cannot be included easily from asm/ headers, and generally shouldn't be used outside of this rather narrow purpose. It's a ktime function, but it's not the usual ktime API. Suggested-by: Thomas Gleixner <tglx@linutronix.de> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Theodore Ts'o <tytso@mit.edu> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> --- include/linux/timex.h | 2 ++ kernel/time/timekeeping.c | 8 ++++++++ 2 files changed, 10 insertions(+)