From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2E0A91E2824; Sun, 24 Nov 2024 12:46:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732452418; cv=none; b=ijqFc9rR1416GCqNgOMYmvbeztdB2QFhpgbHh7oL/WqdzAWH1or9sL1fNHVFpGtx5ACVRo8FpWDosg87/YmG/9rnFQjNey/szuGbj6mNezKApO9giI0Q/fAv+Eec7Wm/y8CYBxDjX0cWGY0UipMpHykgsq8RRzZM61KUnC+9Pt0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732452418; c=relaxed/simple; bh=3RO6TIxlptJxytni1YcI5RLLNoh+vPGWdSQUtJ95D5A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rEhFncZF3WpGU7o1drr11jCiT60BkJHJiJI0zBD6Ug6o9nY1OGVgX4T221X2pGctbV7Zapr5kvJTbioAdb+W335XjQMlQ4BOXHXJQvilIcplkMFAinl89tR7SSNChiZwpZ0EcdmW4Bx2LvlNOUzMHynrLJkLRqKjoy2XoVEjq1k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NtxMJcG0; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NtxMJcG0" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D0531C4CECC; Sun, 24 Nov 2024 12:46:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732452418; bh=3RO6TIxlptJxytni1YcI5RLLNoh+vPGWdSQUtJ95D5A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NtxMJcG059NBMeJp0AMJKdN1wFmpeBGwHRuVb1IlQvOKxO5HGoEyYbyVt64Tn/LxP qi9Mn3sYkVt8kEo3R6YbHh3jM8CNIUwt6hbL0AC82eKnyWzQTdoBGqSy27F60JdjIv q8P3Jnpk3TcIE2ZQVzF3zjdFtlQ3vx1pcAcikOWOSNWx9tpZPAp8QKfT28DyazOeIL ExErK/RIzX3V0ywJu+LMD+zMoBQwL05FGouoZbpgslEMkURVvWJnKHTVjPlIcJsa7x ipKdtk9Xe9bqTLe/3s3oFnOUhXRzbZbUe5gGuBL4wX9oX2AhqG9BUF5VBRA1fY+cOR c+GM2zd73QE8A== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Thomas Gleixner , John Stultz , Sasha Levin , mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, rdunlap@infradead.org, paulmck@kernel.org Subject: [PATCH AUTOSEL 6.11 5/5] timekeeping: Always check for negative motion Date: Sun, 24 Nov 2024 07:46:38 -0500 Message-ID: <20241124124643.3338173-5-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241124124643.3338173-1-sashal@kernel.org> References: <20241124124643.3338173-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.11.10 Content-Transfer-Encoding: 8bit From: Thomas Gleixner [ 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 Acked-by: John Stultz Link: https://lore.kernel.org/all/20241031120328.599430157@linutronix.de Signed-off-by: Sasha Levin --- arch/x86/Kconfig | 1 - kernel/time/Kconfig | 5 ----- kernel/time/timekeeping_internal.h | 7 ------- 3 files changed, 13 deletions(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 4e0b05a6bb5c3..704e50c14938b 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -141,7 +141,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. diff --git a/kernel/time/Kconfig b/kernel/time/Kconfig index 8ebb6d5a106be..b0b97a60aaa6f 100644 --- 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 diff --git a/kernel/time/timekeeping_internal.h b/kernel/time/timekeeping_internal.h index 4ca2787d1642e..1d4854d5c386e 100644 --- a/kernel/time/timekeeping_internal.h +++ b/kernel/time/timekeeping_internal.h @@ -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; -- 2.43.0