From: Jeff Layton <jlayton@kernel.org>
To: John Stultz <jstultz@google.com>
Cc: Jan Kara <jack@suse.cz>, Alexander Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>,
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: Fri, 13 Sep 2024 15:01:18 -0400 [thread overview]
Message-ID: <4e4b1096b322f2998b5e59a861c5fdad410c108a.camel@kernel.org> (raw)
In-Reply-To: <CANDhNCpBpBFrwu85oozKNW0N9_FzYXdpDbmX9sOnT_2oCGDeFw@mail.gmail.com>
On Fri, 2024-09-13 at 11:43 -0700, John Stultz wrote:
> On Fri, Sep 13, 2024 at 5:01 AM Jeff Layton <jlayton@kernel.org> wrote:
> > On Fri, 2024-09-13 at 13:26 +0200, Jan Kara wrote:
> > > So what would be the difference if we did instead:
> > >
> > > old = atomic64_read(&mg_floor);
> > >
> > > and not bother with the cookie? AFAIU this could result in somewhat more
> > > updates to mg_floor (the contention on the mg_floor cacheline would be the
> > > same but there would be more invalidates of the cacheline). OTOH these
> > > updates can happen only if max(current_coarse_time, mg_floor) ==
> > > inode->i_ctime which is presumably rare? What is your concern that I'm
> > > missing?
> > >
> >
> > My main concern is the "somewhat more updates to mg_floor". mg_floor is
> > a global variable, so one of my main goals is to minimize the updates
> > to it. There is no correctness issue in doing what you're saying above
> > (AFAICT anyway), but the window of time between when we fetch the
> > current floor and try to do the swap will be smaller, and we'll end up
> > doing more swaps as a result.
>
> Would it be worth quantifying that cost?
>
There's a patch in the larger set that adds some percpu counters to
count events. One of them was successful floor value swaps. I dropped
that particular counter from the v7 set, but we could resurrect it.
> > Do you have any objection to adding the cookie to this API?
>
> My main concern is it is just a bit subtle. I found it hard to grok
> (though I can be pretty dim sometimes, so maybe that doesn't count for
> much :)
> It seems if it were misused, the fine-grained accessor could
> constantly return coarse grained results when called repeatedly with a
> very stale cookie.
>
> Further, the point about avoiding "too many" mg_floor writes is a
> little fuzzy. It feels almost like folks would need to use the cookie
> update as a tuning knob to balance the granularity of their timestamps
> against the cost of the global mg_floor writes. So this probably needs
> some clear comments to make it more obvious.
>
Fair points. I don't have any hard numbers around it. I'm mainly just
trying to do what I can to keep the floor swaps to an absolute minimum.
This is a global value after all so we really are better off avoiding
cache invalidations.
That said, passing the cookie like this would only open the window a
small amount. I can certainly drop that part of the interface. In the
big scheme of things I doubt it'll make much difference in performance,
and if it does we can always bring it back.
If that sounds OK, I'll send a v8 (after some testing). I have some
comment updates I'd like to add as well.
--
Jeff Layton <jlayton@kernel.org>
next prev parent reply other threads:[~2024-09-13 19:01 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
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 [this message]
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=4e4b1096b322f2998b5e59a861c5fdad410c108a.camel@kernel.org \
--to=jlayton@kernel.org \
--cc=arnd@kernel.org \
--cc=brauner@kernel.org \
--cc=jack@suse.cz \
--cc=jstultz@google.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.