]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
timekeeping: Always check for negative motion
authorThomas Gleixner <tglx@linutronix.de>
Thu, 31 Oct 2024 12:04:08 +0000 (13:04 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 14 Dec 2024 19:03:38 +0000 (20:03 +0100)
[ Upstream commit c163e40af9b2331b2c629fd4ec8b703ed4d4ae39 ]

clocksource_delta() has two variants. One with a check for negative motion,
which is only selected by x86. This is a historic leftover as this function
was previously used in the time getter hot paths.

Since 135225a363ae timekeeping_cycles_to_ns() has unconditional protection
against this as a by-product of the protection against 64bit math overflow.

clocksource_delta() is only used in the clocksource watchdog and in
timekeeping_advance(). The extra conditional there is not hurting anyone.

Remove the config option and unconditionally prevent negative motion of the
readout.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: John Stultz <jstultz@google.com>
Link: https://lore.kernel.org/all/20241031120328.599430157@linutronix.de
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/x86/Kconfig
kernel/time/Kconfig
kernel/time/timekeeping_internal.h

index 7b9a7e8f39acc8e9aeb7d4213e87d71047865f5c..171be04eca1f5dc08f7b84e52a6760d58a0c2fe5 100644 (file)
@@ -145,7 +145,6 @@ config X86
        select ARCH_HAS_PARANOID_L1D_FLUSH
        select BUILDTIME_TABLE_SORT
        select CLKEVT_I8253
-       select CLOCKSOURCE_VALIDATE_LAST_CYCLE
        select CLOCKSOURCE_WATCHDOG
        # Word-size accesses may read uninitialized data past the trailing \0
        # in strings and cause false KMSAN reports.
index 8ebb6d5a106bea9ed6f9f23faadbdae7358cf036..b0b97a60aaa6fc21c93005ef393d56afbac7fa5c 100644 (file)
@@ -17,11 +17,6 @@ config ARCH_CLOCKSOURCE_DATA
 config ARCH_CLOCKSOURCE_INIT
        bool
 
-# Clocksources require validation of the clocksource against the last
-# cycle update - x86/TSC misfeature
-config CLOCKSOURCE_VALIDATE_LAST_CYCLE
-       bool
-
 # Timekeeping vsyscall support
 config GENERIC_TIME_VSYSCALL
        bool
index 4ca2787d1642e2f52bf985607ca3b03785cf9a50..1d4854d5c386e20e141c4cf4d5ca3872a36b4633 100644 (file)
@@ -15,7 +15,6 @@ extern void tk_debug_account_sleep_time(const struct timespec64 *t);
 #define tk_debug_account_sleep_time(x)
 #endif
 
-#ifdef CONFIG_CLOCKSOURCE_VALIDATE_LAST_CYCLE
 static inline u64 clocksource_delta(u64 now, u64 last, u64 mask)
 {
        u64 ret = (now - last) & mask;
@@ -26,12 +25,6 @@ static inline u64 clocksource_delta(u64 now, u64 last, u64 mask)
         */
        return ret & ~(mask >> 1) ? 0 : ret;
 }
-#else
-static inline u64 clocksource_delta(u64 now, u64 last, u64 mask)
-{
-       return (now - last) & mask;
-}
-#endif
 
 /* Semi public for serialization of non timekeeper VDSO updates. */
 extern raw_spinlock_t timekeeper_lock;