]> asedeno.scripts.mit.edu Git - linux.git/commit
timekeeping: Provide NMI safe access to clock realtime
authorThomas Gleixner <tglx@linutronix.de>
Thu, 31 Aug 2017 15:12:48 +0000 (17:12 +0200)
committerThomas Gleixner <tglx@linutronix.de>
Mon, 25 Sep 2017 19:05:59 +0000 (21:05 +0200)
commit4c3711d7fb4763c63b2654f2d07cbe21ca5aadd4
tree8601fdab0f9b823f687d0ae5ddef6b7ef6046710
parent5df32107f609c1f621bcdac0a685c23677ef671e
timekeeping: Provide NMI safe access to clock realtime

The configurable printk timestamping wants access to clock realtime. Right
now there is no ktime_get_real_fast_ns() accessor because reading the
monotonic base and the realtime offset cannot be done atomically. Contrary
to boot time this offset can change during runtime and cause half updated
readouts.

struct tk_read_base was fully packed when the fast timekeeper access was
implemented. commit ceea5e3771ed ("time: Fix clock->read(clock) race around
clocksource changes") removed the 'read' function pointer from the
structure, but of course left the comment stale.

So now the structure can fit a new 64bit member w/o violating the cache
line constraints.

Add real_base to tk_read_base and update it in the fast timekeeper update
sequence.

Implement an accessor which follows the same scheme as the accessor to
clock monotonic, but uses the new real_base to access clock real time.

The runtime overhead for updating real_base is minimal as it just adds two
cache hot values and stores them into an already dirtied cache line along
with the other fast timekeeper updates.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Prarit Bhargava <prarit@redhat.com>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Peter Zijlstra <peterz@infradead,org>
Link: https://lkml.kernel.org/r/1505757060-2004-3-git-send-email-prarit@redhat.com
include/linux/timekeeper_internal.h
include/linux/timekeeping.h
kernel/time/timekeeping.c