Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2521109lqp; Mon, 25 Mar 2024 00:58:13 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVHxwe3x4dQ+RI/faG4v2iORCIq6rBAotw7mzFQF8SP+SZ2MpAEWwusr/bjkfMQXgXaY84zHuWb7ezWV39LeJG5ZdRePJwtTme17kzthw== X-Google-Smtp-Source: AGHT+IFz7O+qctcFGHH6nHGzIXbcTEWfBuxcVLSft1nANUJbOvzQ8OL1KihZiu1b1YsQxsAAloOr X-Received: by 2002:a17:90b:88c:b0:29f:6bfa:207d with SMTP id bj12-20020a17090b088c00b0029f6bfa207dmr4179438pjb.29.1711353493158; Mon, 25 Mar 2024 00:58:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711353493; cv=pass; d=google.com; s=arc-20160816; b=RWgPAPtOQS+v6jVTCOHNwO6OFg+K143kq01JLmEOYtPg/MMuw5KSEEuQByPcyAZYu8 rMJrtdCoCzRA/sMMuccaujxBaeyTckM7caoxAkpIN/zpZ/u72IQPeEStLbAuDyh1d+/2 xWA7MlcXVFQ6zbWGEFmc6d1NKlBXZ+J3rBsKy1px4woincqUvUzyb0JvIFKbYt+45H/b R3U1RqDFulP+FjVMXAwd93CfWPoFTVnVeBoCnWemMBa7M1m8G91PQd88eYVOXzzDYFDb ImRp/42L0Xc8rmiFo4TTu5InRgz5meWPrHcosWsiAfh1BKHBRF/PWhGnbMwKJsrlvH1t cqnQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=UYmnOh8TgRKQOrluk/cl8fYwerD3uNLFTowMbeWUQsE=; fh=Kup36vPmDrRX/ZED4HiLo7D05zuBWldEjkgKP/N/E5c=; b=YEJ4wK8WTNeUxt1o4+MyAOHdVdajZGsMDPpt+qvZjOVkKITHGhdxgiBGBPib0EcNsz t56KE5cfKlC7NbqhYBoZTbnXCRJD+Vn209/L2hb59h7rDUGxgoq+qeiRQptvgsQXW+Nl 54sl6Wcqki3DqMYg0rR48K5cev9z1/GE+Dbw2Tbfgywywln4Zbw2e95qisW346AXSmU4 v0+4R3yS1eyip0besvXZJ5oGVTHWtEuz5hzCTqcjmDAmeLZQkidu4X92z0VlcreeF3BO uEMEqTLJ/ar/womKxbYxwRmyPpUL0NQ5cM8+yQbYUJf68/p+iZWv22v4SOTiamEW/erE XSxw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uLrUItxU; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-114950-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-114950-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id l6-20020a17090a72c600b0029fa720112dsi10860751pjk.8.2024.03.25.00.58.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 00:58:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-114950-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uLrUItxU; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-114950-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-114950-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 168E6B2CAF3 for ; Mon, 25 Mar 2024 07:11:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 88F3E2DC9AF; Mon, 25 Mar 2024 00:57:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="uLrUItxU" 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 9564A179FCF; Sun, 24 Mar 2024 23:41:04 +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=1711323665; cv=none; b=tVYOna4ldydOQBhTgHaoaf9z4lQvXZliUt67X0JxZtNbaYhVW3eAMTXa8Rc8pkDTh8eGa/54JHF6cE1GOzCr3VLkv22bQ9crYwqO5Th0A2uIS/t7rxl5SmC3kFleQd1T/z/agoYnJSDVerRJ2j6Ayj8bD4oFOdf53BcJjSqPF1I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711323665; c=relaxed/simple; bh=r5p49GZRFmtuKgVaabBtNqYpK5s4aOtan8S6DcAYzIw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=m1QbYXgR05cNzEDZBSwFrE4MvJydu/zyfz6ZBlUH1X+oFDT0qj3tmg+2b2+jycYVhwb+qqAUcUSQ/kOSYLQacr55BnxVw56dhjpdC2eDrUpJQez4FKS5hMIxQfmqKjmL+hOSC5OOTMzIOR56xjTw/95Jw2yRa6oqussZjTGm7Js= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uLrUItxU; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id BCE92C433F1; Sun, 24 Mar 2024 23:41:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711323664; bh=r5p49GZRFmtuKgVaabBtNqYpK5s4aOtan8S6DcAYzIw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uLrUItxUMo2C8kbAaL1jlnYCyupJ6CMqnHgjG1Zrxg07gRtCLRHTgVaoxGgGyZsZl dVDZAWuyhLXgpPkNpre8FsY58mE4KMTt8lRLyeoOlkHT/YEux1wP+B+aCxC5O+AHNp NLHwxI7+cpsJrZgJS6ZpY/rLzrxrgBvEOtBhuavQvBvyGDn+hv/rF88ejXxYotMydE 5iSSXOLJaXwdhRrMEGKfhqP1yK/5JVn5qG0NDZXnaKEzHd11JDGbvDmpNPS4kVJPB4 aXYBfg4p6iFpY+MUp2FdAQPhkg7tOrprl2GXfZwKEmQNfBTjYGFWtpJgQ0f9w2gCSp GyBmhl6w/IqjQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Peter Hilber , Thomas Gleixner , John Stultz , Sasha Levin Subject: [PATCH 5.10 036/238] timekeeping: Fix cross-timestamp interpolation on counter wrap Date: Sun, 24 Mar 2024 19:37:04 -0400 Message-ID: <20240324234027.1354210-37-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324234027.1354210-1-sashal@kernel.org> References: <20240324234027.1354210-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 Content-Transfer-Encoding: 8bit From: Peter Hilber [ Upstream commit 84dccadd3e2a3f1a373826ad71e5ced5e76b0c00 ] cycle_between() decides whether get_device_system_crosststamp() will interpolate for older counter readings. cycle_between() yields wrong results for a counter wrap-around where after < before < test, and for the case after < test < before. Fix the comparison logic. 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-2-peter.hilber@opensynergy.com Signed-off-by: Sasha Levin --- kernel/time/timekeeping.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index d9b48f7a35e0d..6a8a610b19717 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -1173,7 +1173,7 @@ static bool cycle_between(u64 before, u64 test, u64 after) { if (test > before && test < after) return true; - if (test < before && before > after) + if (before > after && (test > before || test < after)) return true; return false; } -- 2.43.0