From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 705D2CCFA16 for ; Mon, 30 Sep 2024 19:13:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E5696280022; Mon, 30 Sep 2024 15:13:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DE002280017; Mon, 30 Sep 2024 15:13:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C8030280022; Mon, 30 Sep 2024 15:13:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id AA375280017 for ; Mon, 30 Sep 2024 15:13:36 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 5DE9E1A0501 for ; Mon, 30 Sep 2024 19:13:36 +0000 (UTC) X-FDA: 82622353632.27.296D3B5 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by imf23.hostedemail.com (Postfix) with ESMTP id 57222140018 for ; Mon, 30 Sep 2024 19:13:34 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b="gJ/KxS1M"; dkim=pass header.d=linutronix.de header.s=2020e header.b=u6tZgxkK; dmarc=pass (policy=none) header.from=linutronix.de; spf=pass (imf23.hostedemail.com: domain of tglx@linutronix.de designates 193.142.43.55 as permitted sender) smtp.mailfrom=tglx@linutronix.de ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727723595; a=rsa-sha256; cv=none; b=QjcJl9JNqlE1QencZVccQDwRoFnCSwWZQLJ38iL4OsMaBEH9aJAac9Xr/+cWkAiqEadHzl xXLNn+2xG13CAPGzUQZumgOZ5nmF1ZEPknFeSmlftutE8p60IEWjKsVKZEv3RJx4foVRN1 vXdUBkUugmhr5ADXVqlqwx7TJqygRrU= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b="gJ/KxS1M"; dkim=pass header.d=linutronix.de header.s=2020e header.b=u6tZgxkK; dmarc=pass (policy=none) header.from=linutronix.de; spf=pass (imf23.hostedemail.com: domain of tglx@linutronix.de designates 193.142.43.55 as permitted sender) smtp.mailfrom=tglx@linutronix.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1727723595; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=fFBOud7anAZyztkYeQWuXr4vYsC9F6E8D/HPnn/0BOg=; b=2GvI0a7yxff0o2xEez0+aqfE8WkLWNNDjt5hWpsPcPyPTEmCagAEuvo4OzVa8apucxJena LZ1iFrwugS5iiF+19k7oIGl2MWt8m/rTovfeSx2GoKTkIQvgt4JeYalVMb60xaIEfxmlG7 B3DRIm8NjikDueY7EfR3NUWhr8D9U3U= From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1727723611; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=fFBOud7anAZyztkYeQWuXr4vYsC9F6E8D/HPnn/0BOg=; b=gJ/KxS1M9QBiD9jT7XM70vomQS8njPKEUEFPhzAr1j+v8H8tYnKZFu/E0imRNBPUn6wmQM 63zxh87CjWjrcX8XeQp2CuaTKNGKsl9Gh0gmWMrzQhGuH5yRH7VBCaPq27hRMG/rtKfC1J NyA1NeSHi1DtWXEDZ1OBlegulrkgvwMNNFLReMPCu6H/lx5aE5d1Jyr+X1asET1BArubpi MzfGQLeV0JIL5UnJsvkdHXulEKCZVIi5t4GHKmVkC0+Qi/oAG5rELQYrnQotOTXfqsMOE8 BRCV4t1BqGMBxTZeBO1nDDqTg11Iix2OEul8FtsHI0ok5j2ZOPlfZFTlS2xG8w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1727723611; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=fFBOud7anAZyztkYeQWuXr4vYsC9F6E8D/HPnn/0BOg=; b=u6tZgxkKVS2Jwn34typ3Qtq8h/7YSyYXitKctJvkyMHyOED4yEOoKXy+UnCqzMM3x56A1E YX6g2x7VODFL8aBw== To: Jeff Layton , John Stultz , Stephen Boyd , Alexander Viro , Christian Brauner , Jan Kara , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Jonathan Corbet , Chandan Babu R , "Darrick J. Wong" , Theodore Ts'o , Andreas Dilger , Chris Mason , Josef Bacik , David Sterba , Hugh Dickins , Andrew Morton , Chuck Lever , Vadim Fedorenko Cc: Randy Dunlap , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-mm@kvack.org, Jeff Layton Subject: Re: [PATCH v8 01/11] timekeeping: move multigrain timestamp floor handling into timekeeper In-Reply-To: <20240914-mgtime-v8-1-5bd872330bed@kernel.org> References: <20240914-mgtime-v8-0-5bd872330bed@kernel.org> <20240914-mgtime-v8-1-5bd872330bed@kernel.org> Date: Mon, 30 Sep 2024 21:13:30 +0200 Message-ID: <87bk050xb9.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain X-Rspam-User: X-Stat-Signature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ZYZvCFIhbtDVfoBCJs0z4PFttpFAxh6mjc6y0szodiRzgOCZp78cHlOQbbykRVdo8Ih2d3Ubah15fzCeJxSgQnKKGW9X/8+u2jnp+apBZFIJCUKd5uMN0TEkVyEG8W5LEavyWmu3nHLVJXLD54ZgHJA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Sat, Sep 14 2024 at 13:07, Jeff Layton wrote: > For multigrain timestamps, we must keep track of the latest timestamp > that has ever been handed out, and never hand out a coarse time below > that value. How is that correct when the clock is off by an hour and then set back to the correct value? Then you'd get the same stale timestamp for an hour unless something invokes ktime_get_real_ts64_mg() which will set the "latest" timestamp back to a time before the previous one. > Add a static singleton atomic64_t into timekeeper.c that we can use to > keep track of the latest fine-grained time ever handed out. This is > tracked as a monotonic ktime_t value to ensure that it isn't affected by > clock jumps. That's just wishful thinking. ktime_get_real_ts64_mg(ts) ts = Tmono_1 + offset_1; // TReal_1 floor = Tmono_1; // newtime < TReal_1 clock_settime(REALTIME, newtime); xtime = newtime; // TReal_2 offset_2 = offset_1 + Treal_2 - TReal(now); --> offset_2 < offset_1 ktime_get_coarse_real_ts64_mg(ts) ts = tk_xtime(); // TReal_2 offs = offset_2; if (Tmono_1 + offset_2 > ts) ts = Tmono_1 + offset_2; // Not taken So this returns T_Real_2 because offset_2 < offset_1 and therefore Tmono_1 + offset_2 < TReal_2 so the returned time will jump backwards vs. TReal_1 as it should because that's the actual time, no? So if that's the intended behaviour then the changelog is misleading at best. If the intention is to never return a value < TReal_1 then this does not work. You can make it work by using the Realtime timestamp as floor, but that'd be more than questionable vs. clock_settime() making the clock go backwards. Thanks, tglx