Skip to content

Commit e26cbab

Browse files
KAGA-KOKOgregkh
authored andcommitted
timekeeping: Always check for negative motion
[ Upstream commit c163e40 ] 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 135225a 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 <[email protected]> Acked-by: John Stultz <[email protected]> Link: https://lore.kernel.org/all/[email protected] Signed-off-by: Sasha Levin <[email protected]>
1 parent c7559dc commit e26cbab

File tree

3 files changed

+0
-13
lines changed

3 files changed

+0
-13
lines changed

arch/x86/Kconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ config X86
145145
select ARCH_HAS_PARANOID_L1D_FLUSH
146146
select BUILDTIME_TABLE_SORT
147147
select CLKEVT_I8253
148-
select CLOCKSOURCE_VALIDATE_LAST_CYCLE
149148
select CLOCKSOURCE_WATCHDOG
150149
# Word-size accesses may read uninitialized data past the trailing \0
151150
# in strings and cause false KMSAN reports.

kernel/time/Kconfig

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@ config ARCH_CLOCKSOURCE_DATA
1717
config ARCH_CLOCKSOURCE_INIT
1818
bool
1919

20-
# Clocksources require validation of the clocksource against the last
21-
# cycle update - x86/TSC misfeature
22-
config CLOCKSOURCE_VALIDATE_LAST_CYCLE
23-
bool
24-
2520
# Timekeeping vsyscall support
2621
config GENERIC_TIME_VSYSCALL
2722
bool

kernel/time/timekeeping_internal.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ extern void tk_debug_account_sleep_time(const struct timespec64 *t);
1515
#define tk_debug_account_sleep_time(x)
1616
#endif
1717

18-
#ifdef CONFIG_CLOCKSOURCE_VALIDATE_LAST_CYCLE
1918
static inline u64 clocksource_delta(u64 now, u64 last, u64 mask)
2019
{
2120
u64 ret = (now - last) & mask;
@@ -26,12 +25,6 @@ static inline u64 clocksource_delta(u64 now, u64 last, u64 mask)
2625
*/
2726
return ret & ~(mask >> 1) ? 0 : ret;
2827
}
29-
#else
30-
static inline u64 clocksource_delta(u64 now, u64 last, u64 mask)
31-
{
32-
return (now - last) & mask;
33-
}
34-
#endif
3528

3629
/* Semi public for serialization of non timekeeper VDSO updates. */
3730
extern raw_spinlock_t timekeeper_lock;

0 commit comments

Comments
 (0)