From: Thomas Gleixner <tglx@linutronix.de>
To: LKML <linux-kernel@vger.kernel.org>
Cc: John Stultz <jstultz@google.com>,
Anna-Maria Behnsen <anna-maria@linutronix.de>,
Frederic Weisbecker <frederic@kernel.org>,
Stephen Boyd <sboyd@kernel.org>,
Peter Zijlstra <peterz@infradead.org>
Subject: [patch 2/2] timekeeping: Always check for negative motion
Date: Thu, 31 Oct 2024 13:04:08 +0100 (CET) [thread overview]
Message-ID: <20241031120328.599430157@linutronix.de> (raw)
In-Reply-To: 20241031115448.978498636@linutronix.de
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>
---
arch/x86/Kconfig | 1 -
kernel/time/Kconfig | 5 -----
kernel/time/timekeeping_internal.h | 7 -------
3 files changed, 13 deletions(-)
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -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.
--- a/kernel/time/Kconfig
+++ b/kernel/time/Kconfig
@@ -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
--- a/kernel/time/timekeeping_internal.h
+++ b/kernel/time/timekeeping_internal.h
@@ -30,7 +30,6 @@ static inline void timekeeping_inc_mg_fl
#endif
-#ifdef CONFIG_CLOCKSOURCE_VALIDATE_LAST_CYCLE
static inline u64 clocksource_delta(u64 now, u64 last, u64 mask)
{
u64 ret = (now - last) & mask;
@@ -41,12 +40,6 @@ static inline u64 clocksource_delta(u64
*/
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. */
unsigned long timekeeper_lock_irqsave(void);
next prev parent reply other threads:[~2024-10-31 12:04 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-31 12:04 [patch 0/2] timekeeping: Fall cleaning Thomas Gleixner
2024-10-31 12:04 ` [patch 1/2] timekeeping: Remove CONFIG_DEBUG_TIMEKEEPING Thomas Gleixner
2024-11-02 4:14 ` John Stultz
2024-11-02 9:24 ` [tip: timers/core] " tip-bot2 for Thomas Gleixner
2024-10-31 12:04 ` Thomas Gleixner [this message]
2024-11-02 4:15 ` [patch 2/2] timekeeping: Always check for negative motion John Stultz
2024-11-02 9:24 ` [tip: timers/core] " tip-bot2 for Thomas Gleixner
2024-11-25 0:48 ` [patch 2/2] " Guenter Roeck
2024-11-27 22:08 ` John Stultz
2024-11-27 23:02 ` Guenter Roeck
2024-11-28 14:51 ` Thomas Gleixner
2024-11-28 15:30 ` Guenter Roeck
2024-11-29 12:16 ` Thomas Gleixner
2024-11-29 16:09 ` Guenter Roeck
2024-11-30 11:09 ` Thomas Gleixner
2024-11-30 18:21 ` Guenter Roeck
2024-12-03 10:16 ` [patch] clocksource: Make negative motion detection more robust Thomas Gleixner
2024-12-05 15:11 ` [tip: timers/urgent] " tip-bot2 for Thomas Gleixner
2024-11-28 15:57 ` [patch 2/2] timekeeping: Always check for negative motion Guenter Roeck
2024-11-28 17:13 ` Guenter Roeck
2024-11-28 17:47 ` Guenter Roeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241031120328.599430157@linutronix.de \
--to=tglx@linutronix.de \
--cc=anna-maria@linutronix.de \
--cc=frederic@kernel.org \
--cc=jstultz@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=sboyd@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox