From patchwork Mon Feb 19 16:35:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 203172 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp1397525dyc; Mon, 19 Feb 2024 08:35:45 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV0gE4yT+IEensqkYwRPskajvoOhyrH0UiguuN8LgfbRSdjkJXAnP+TZ55TUELNVvz1z6JLXMCg3Ai54A/xoQyLK+e4Qw== X-Google-Smtp-Source: AGHT+IEOsxVIWNs6Pym2xEiOL0LtZENd3P/uBk24twlE8Jd97FCSmqMFnotmqGtLR/Yel4bTzSw/ X-Received: by 2002:a17:906:702:b0:a3d:482f:3fc4 with SMTP id y2-20020a170906070200b00a3d482f3fc4mr8164927ejb.70.1708360544956; Mon, 19 Feb 2024 08:35:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708360544; cv=pass; d=google.com; s=arc-20160816; b=Ba+rqrb8P2W1DUtT9ONBsyxJlA9K5zZevDIFm2FdyKKo+YeSQzJkHbqzlhdzhRlkes zsVI49yTCuZKFCjMYu74LTiX7RmdjPDokKXpS/tnnwuiQeyIh6e7nsJVDYLO9l2bFGBy akStISjcqMjaSYjhCeFa/D1QWa2NxWAFyStfkEQiFyutNwhmwhx4BGqDmYZqlFfi01Uo ShHA4F+G3vZv9aK0bCL1rKJ5u+AYENb4ddOstn09cAoF1NJ6hYAzhcAWwJnolGz1Skcs nviPXu2CjtaYthPk/1Txas9J34/VLTpjNjYLOTFQKX1B8XzeQ9ngXa5EeFQ0y/0tyIeR 8zBQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:precedence:robot-unsubscribe:robot-id :message-id:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:in-reply-to:cc:subject:to:reply-to:sender :from:dkim-signature:dkim-signature:date; bh=hR2ba7cr0Kap8YHhF1/mw/Ks29O4RybZ9BPUoZmrFYk=; fh=B4vXv6JWaA8VKOxUe7McRUgOfBy3+ZAyf66jm8YfOLA=; b=FoMOmYjJpaMDfsIZobYJ+CvNqRNVxUeJOsn0WlyLujla129owmwB7xpTdFKID18FrF arN2nonzgg4uNn9q3RA+DSpChNWSz37w5KBaxXJxMHZuJyQJjZznd3vscAe7tO8FXeBg duQH1Mp/tssB5lLXWkfP0v1EnJMOG5AsLciplDEUswspa6vZL0o3YnvNTI2ayZpofaq6 6u6v1kaI096XC/G1BoPLQRp07bYV6nEGoT2WY3hk0EQdtxmdFCaNDoiwqOrSwJl8bt89 0tLfEF89VM5utFXoJbz9P+Koap4c5lnt4ApsjXSWJuXu/8nVlYXcweU/E8t/bRaahq0z SePQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=nAhslH5E; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=7fWOQ432; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-71686-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71686-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id i21-20020a1709064ed500b00a3e70a922e4si1431830ejv.892.2024.02.19.08.35.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 08:35:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71686-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=nAhslH5E; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=7fWOQ432; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-71686-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71686-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 933461F2497F for ; Mon, 19 Feb 2024 16:35:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9E7DF40C0E; Mon, 19 Feb 2024 16:35:22 +0000 (UTC) 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" 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 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785604888511600860 X-GMAIL-MSGID: 1791345866808806519 The following commit has been merged into the timers/core branch of tip: Commit-ID: 14274d0bd31b4debf28284604589f596ad2e99f2 Gitweb: https://git.kernel.org/tip/14274d0bd31b4debf28284604589f596ad2e99f2 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 == 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 == 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 supporting 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@opensynergy.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 = tk->tkr_raw.base; - nsec_real = timekeeping_cycles_to_ns(&tk->tkr_mono, - system_counterval.cycles); - nsec_raw = timekeeping_cycles_to_ns(&tk->tkr_raw, - system_counterval.cycles); + nsec_real = timekeeping_cycles_to_ns(&tk->tkr_mono, cycles); + nsec_raw = timekeeping_cycles_to_ns(&tk->tkr_raw, cycles); } while (read_seqcount_retry(&tk_core.seq, seq)); xtstamp->sys_realtime = ktime_add_ns(base_real, nsec_real);