From nobody Wed Dec 17 04:13:50 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 585BA3FB21; Mon, 19 Feb 2024 16:35:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708360519; cv=none; b=QRp6k1AfntkwYpM/u7F3PC0di5pY7ilGY9wvULQI/7TGLsJBC19S6Klsyyvkd+mDNuSxJ6CrquMmjCOzCItsVNDlXgj/g1WdQhfWPRvs8J2rdh+mmz4Y2xnnyIPnJwGNXbD9cz2moxrxotDgcJIXHEWag/nBKHBGSyPgLnN79qk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708360519; c=relaxed/simple; bh=Idw1vDDtc6dcTHvMpbTfp8KxEfRv/UVvvHnfEt4KQ0Q=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=OI+qS8l1hhl/I4tt2qYYe3tD5hdW+kQ2yMk6zh4xiRNyIIEDQYACfMJXOge+R31yOiQlcbDHdffmg+w8fCzZQXrbees5hPr+5sqk3Vdbm2o7ie2kJFJPR+xlc8V9xiouW8la7L9lI7SCnwJbbuSrjxS6C9U2Ra3h23IL1F1u5YU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=nAhslH5E; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=7fWOQ432; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="nAhslH5E"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="7fWOQ432" Date: Mon, 19 Feb 2024 16:35:15 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1708360516; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hR2ba7cr0Kap8YHhF1/mw/Ks29O4RybZ9BPUoZmrFYk=; b=nAhslH5E1ql+w5f3S5nII6zTIQgHnyDDv7rM2k+m1kMUDL9C4RP1HTyybeKl4NhcYK69Gs 30m8iwUl0T8uh26IfHRugC9TAi2uIU8IvBG6QUfmS4gmvqK2LH2Tch+tQYtSZ6kppiASoQ o8igw8Is2VKyyqH8S9daDHoCiVZl4IfZOdXccPXQTrw6usarNm1NN0vYSUKGHD03CCDCq9 UfcEZIGrB5cyjyZrjnv/GNUH70IoJ5kt+/19GaHM9yGy/pnJU9EpPnRrS0G06oWyDNKA8V 884D5Vms08IMnsL3pxZNfZjC2ATEUCHgvX2zTz4eU3HzHzTdKzvwIuNGOrgDNw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1708360516; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hR2ba7cr0Kap8YHhF1/mw/Ks29O4RybZ9BPUoZmrFYk=; b=7fWOQ432qxMIkgAdXXgE7sxmHtZR4wKWksi5gew5kAEpYHmQOVemtAdVimNILyO/p8s1dl puZVpQHl7ycickBQ== From: "tip-bot2 for Peter Hilber" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: timers/core] timekeeping: Fix cross-timestamp interpolation for non-x86 Cc: Peter Hilber , Thomas Gleixner , John Stultz , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20231218073849.35294-4-peter.hilber@opensynergy.com> References: <20231218073849.35294-4-peter.hilber@opensynergy.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <170836051538.398.6736189078796081366.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the timers/core branch of tip: Commit-ID: 14274d0bd31b4debf28284604589f596ad2e99f2 Gitweb: https://git.kernel.org/tip/14274d0bd31b4debf28284604589f596a= d2e99f2 Author: Peter Hilber AuthorDate: Mon, 18 Dec 2023 08:38:41 +01:00 Committer: Thomas Gleixner CommitterDate: Mon, 19 Feb 2024 12:18:51 +01:00 timekeeping: Fix cross-timestamp interpolation for non-x86 So far, get_device_system_crosststamp() unconditionally passes system_counterval.cycles to timekeeping_cycles_to_ns(). But when interpolating system time (do_interp =3D=3D true), system_counterval.cycles= is before tkr_mono.cycle_last, contrary to the timekeeping_cycles_to_ns() expectations. On x86, CONFIG_CLOCKSOURCE_VALIDATE_LAST_CYCLE will mitigate on interpolating, setting delta to 0. With delta =3D=3D 0, xtstamp->sys_monoraw and xtstamp->sys_realtime are then set to the last update time, as implicitly expected by adjust_historical_crosststamp(). On other architectures, the resulting nonsense xtstamp->sys_monoraw and xtstamp->sys_realtime corrupt the xtstamp (ts) adjustment in adjust_historical_crosststamp(). Fix this by deriving xtstamp->sys_monoraw and xtstamp->sys_realtime from the last update time when interpolating, by using the local variable "cycles". The local variable already has the right value when interpolating, unlike system_counterval.cycles. Fixes: 2c756feb18d9 ("time: Add history to cross timestamp interface suppor= ting slower devices") Signed-off-by: Peter Hilber Signed-off-by: Thomas Gleixner Acked-by: John Stultz Link: https://lore.kernel.org/r/20231218073849.35294-4-peter.hilber@opensyn= ergy.com --- kernel/time/timekeeping.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 4e9f2f8..8aab7ed 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -1261,10 +1261,8 @@ int get_device_system_crosststamp(int (*get_time_fn) tk_core.timekeeper.offs_real); base_raw =3D tk->tkr_raw.base; =20 - nsec_real =3D timekeeping_cycles_to_ns(&tk->tkr_mono, - system_counterval.cycles); - nsec_raw =3D timekeeping_cycles_to_ns(&tk->tkr_raw, - system_counterval.cycles); + nsec_real =3D timekeeping_cycles_to_ns(&tk->tkr_mono, cycles); + nsec_raw =3D timekeeping_cycles_to_ns(&tk->tkr_raw, cycles); } while (read_seqcount_retry(&tk_core.seq, seq)); =20 xtstamp->sys_realtime =3D ktime_add_ns(base_real, nsec_real);