summaryrefslogtreecommitdiffstats
path: root/kernel/time
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2022-04-14 16:55:47 +0200
committerThomas Gleixner <tglx@linutronix.de>2022-04-14 16:55:47 +0200
commitce8abf340e40e1126bfcb9e7679b3d6b524ae3e0 (patch)
tree4f009a42fa3c00d7e2d2fd83b59023674d2e34ba /kernel/time
parentfde33ca4cb2bae6472714123b451475fdfd9995c (diff)
parent3dc6ffae2da201284cb24af66af77ee0bbb2efaa (diff)
downloadlinux-ce8abf340e40e1126bfcb9e7679b3d6b524ae3e0.tar.bz2
Merge tag 'tai-for-tracing' into timers/core
Pull in the NMI safe TAI accessor which was provided for the tracing tree to prepare for further changes in this area.
Diffstat (limited to 'kernel/time')
-rw-r--r--kernel/time/timekeeping.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index dcdcb85121e4..2c22023fbf5f 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -532,6 +532,23 @@ u64 notrace ktime_get_boot_fast_ns(void)
}
EXPORT_SYMBOL_GPL(ktime_get_boot_fast_ns);
+/**
+ * ktime_get_tai_fast_ns - NMI safe and fast access to tai clock.
+ *
+ * The same limitations as described for ktime_get_boot_fast_ns() apply. The
+ * mono time and the TAI offset are not read atomically which may yield wrong
+ * readouts. However, an update of the TAI offset is an rare event e.g., caused
+ * by settime or adjtimex with an offset. The user of this function has to deal
+ * with the possibility of wrong timestamps in post processing.
+ */
+u64 notrace ktime_get_tai_fast_ns(void)
+{
+ struct timekeeper *tk = &tk_core.timekeeper;
+
+ return (ktime_get_mono_fast_ns() + ktime_to_ns(data_race(tk->offs_tai)));
+}
+EXPORT_SYMBOL_GPL(ktime_get_tai_fast_ns);
+
static __always_inline u64 __ktime_get_real_fast(struct tk_fast *tkf, u64 *mono)
{
struct tk_read_base *tkr;