From: John Stultz <jstultz@google.com>
To: Jeff Layton <jlayton@kernel.org>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
Thomas Gleixner <tglx@linutronix.de>,
Stephen Boyd <sboyd@kernel.org>, Arnd Bergmann <arnd@kernel.org>,
Vadim Fedorenko <vadim.fedorenko@linux.dev>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel test robot <oliver.sang@intel.com>
Subject: Re: [PATCH v2] timekeeping: move multigrain timestamp floor handling into timekeeper
Date: Thu, 12 Sep 2024 13:35:41 -0700 [thread overview]
Message-ID: <CANDhNCo-BWqpX1aWi8-q1RaAA_4KigUPcaEML6yCb2EksAX=vA@mail.gmail.com> (raw)
In-Reply-To: <CANDhNCoLCbAYRtA+kjVNiTeNZg6UtCycNpNievLboXbjNU-a9g@mail.gmail.com>
On Thu, Sep 12, 2024 at 1:33 PM John Stultz <jstultz@google.com> wrote:
>
> On Thu, Sep 12, 2024 at 1:18 PM Jeff Layton <jlayton@kernel.org> wrote:
> > On Thu, 2024-09-12 at 13:11 -0700, John Stultz wrote:
> > > On Thu, Sep 12, 2024 at 11:02 AM Jeff Layton <jlayton@kernel.org> wrote:
> > > But instead, it seems like if something has happened since the cookie
> > > value was saved (another cpu getting a fine grained timestamp), your
> > > ktime_get_real_ts64_mg() will fall back to returning the same coarse
> > > grained time saved to the cookie, as if no time had past?
> > >
> > > It seems like that could cause problems:
> > >
> > > cpu1 cpu2
> > > --------------------------------------------------------------------------
> > > t2a = ktime_get_coarse_real_ts64_mg
> > > t1a = ktime_get_coarse_real_ts64_mg()
> > > t1b = ktime_get_real_ts64_mg(t1a)
> > >
> > > t2b = ktime_get_real_ts64_mg(t2a)
> > >
> > > Where t2b will seem to be before t1b, even though it happened afterwards.
> > >
> >
> > Ahh no, the subtle thing about atomic64_try_cmpxchg is that it
> > overwrites "old" with the value that was currently there in the event
> > that the cmp fails.
>
> Ah, ok. Thank you for the explanation there!
>
> > So, the try_cmpxchg there will either swap the new value into place, or
> > if it was updated in the meantime, "old" will now refer to the value
> > that's currently in the floor word. Either is fine in this case, so we
> > don't need to retry anything.
>
>
> Though if cpu2 then made another call to
> ktime_get_coarse_real_ts64_mg(), the value returned there will be the
> same as t1b? and would be before t2b?
Oh, no. Apologies again, as I see t2b would be the same as t1b as well. Ok.
-john
next prev parent reply other threads:[~2024-09-12 20:35 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-12 18:02 [PATCH v2] timekeeping: move multigrain timestamp floor handling into timekeeper Jeff Layton
2024-09-12 20:11 ` John Stultz
2024-09-12 20:15 ` John Stultz
2024-09-12 20:18 ` Jeff Layton
2024-09-12 20:33 ` John Stultz
2024-09-12 20:35 ` John Stultz [this message]
2024-09-13 11:26 ` Jan Kara
2024-09-13 12:01 ` Jeff Layton
2024-09-13 18:43 ` John Stultz
2024-09-13 19:01 ` Jeff Layton
2024-09-16 10:41 ` Jan Kara
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CANDhNCo-BWqpX1aWi8-q1RaAA_4KigUPcaEML6yCb2EksAX=vA@mail.gmail.com' \
--to=jstultz@google.com \
--cc=arnd@kernel.org \
--cc=brauner@kernel.org \
--cc=jack@suse.cz \
--cc=jlayton@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=oliver.sang@intel.com \
--cc=sboyd@kernel.org \
--cc=tglx@linutronix.de \
--cc=vadim.fedorenko@linux.dev \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).