From: Christian Brauner <brauner@kernel.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
linux-fsdevel@vger.kernel.org, Mateusz Guzik <mjguzik@gmail.com>,
Eric Dumazet <edumazet@google.com>,
"Paul E. McKenney" <paulmck@kernel.org>
Subject: Re: [RFC] why do we need smp_rmb/smp_wmb pair in fd_install()/expand_fdtable()?
Date: Thu, 8 Aug 2024 15:20:05 +0200 [thread overview]
Message-ID: <20240808-dates-pechschwarz-0cccfed2c605@brauner> (raw)
In-Reply-To: <CAHk-=wgse0ui5sJgNGSvqvYw_BDTcObqdqcwN1BxgCqKBiiGzQ@mail.gmail.com>
On Wed, Aug 07, 2024 at 08:06:31PM GMT, Linus Torvalds wrote:
> On Wed, 7 Aug 2024 at 19:50, Al Viro <viro@zeniv.linux.org.uk> wrote:
> >
> > What's the problem with droping both barriers and turning that
> > into
> > expanded = expand_fdtable(files, nr);
> > smp_store_release(&files->resize_in_progress, false);
> > and
> > if (unlikely(smp_load_acquire(&files->resize_in_progress))) {
> > ....
> > return;
> > }
>
> That should be fine. smp_store_release()->smp_load_acquire() is the
> more modern model, and the better one. But I think we simply have a
> long history of using the old smp_wmb()->smp_rmb() model, so we have a
> lot of code that does that.
>
> On x86, there's basically no difference - in all cases it ends up
> being just an instruction scheduling barrier.
>
> On arm64, store_release->load_acquire is likely better, but obviously
> micro-architectural implementation issues might make it a wash.
>
> On other architectures, there probably isn't a huge difference, but
> acquire/release can be more expensive if the architecture is
> explicitly designed for the old-style rmb/wmb model.
>
> So on alpha, for example, store_release->load_acquire ends up being a
> full memory barrier in both cases (rmb is always a full memory barrier
> on alpha), which is hugely more expensive than wmb (well, again, in
> theory this is all obviously dependent on microarchitectures, but wmb
> in particular is very cheap unless the uarch really screwed the pooch
> and just messed up its barriers entirely).
>
> End result: wmb/rmb is usually never _horrific_, while release/acquire
> can be rather expensive on bad machines.
>
> But release/acquire is the RightThing(tm), and the fact that alpha
> based its ordering on the bad old model is not really our problem.
>
> So I'm ok with just saying "screw bad memory orderings, go with the
> modern model"
So that's what confused me in your earlier mail in the other thread
where the question around smp_{r,w}mb() and smp_store_release() and
smp_load_acquire() already came up.
Basically, I had always used smp_load_acquire() and smp_store_release()
based on the assumption that they're equivalent to smp_{r,w}mb().
But then multiple times people brought up that supposedly smp_rmb() and
smp_wmb() are cheaper because they only do load or store ordering
whereas smp_{load,store}_{acquire,release}() do load and store ordering.
And it doesn't help that we seemingly don't have a practical guideline
of the form "Generally prefer smp_load_acquire() and smp_store_release()
over smp_rmb() and smp_wmb()." written down anywhere. That really would
shortcut decisions such as this.
next prev parent reply other threads:[~2024-08-08 13:20 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-08 2:50 [RFC] why do we need smp_rmb/smp_wmb pair in fd_install()/expand_fdtable()? Al Viro
2024-08-08 3:06 ` Linus Torvalds
2024-08-08 3:35 ` Al Viro
2024-08-08 3:46 ` Al Viro
2024-08-08 6:08 ` Mateusz Guzik
2024-12-05 12:03 ` [RFC PATCH] fs: elide the smp_rmb fence in fd_install() Mateusz Guzik
2024-12-05 14:18 ` Al Viro
2024-12-05 14:43 ` Mateusz Guzik
2024-12-05 18:41 ` Paul E. McKenney
2024-12-05 19:03 ` Mateusz Guzik
2024-12-05 20:01 ` Paul E. McKenney
2024-12-05 20:15 ` Mateusz Guzik
2024-12-05 21:17 ` Paul E. McKenney
2024-12-05 19:26 ` Linus Torvalds
2024-12-05 19:47 ` Mateusz Guzik
2024-12-05 20:11 ` Paul E. McKenney
2024-12-06 12:11 ` Christian Brauner
2024-12-05 20:06 ` Paul E. McKenney
2024-12-05 14:46 ` Jan Kara
2024-12-05 15:01 ` Mateusz Guzik
2024-12-05 15:29 ` Jan Kara
2024-12-05 15:36 ` Mateusz Guzik
2024-12-06 15:32 ` Jan Kara
2024-12-05 14:58 ` Christian Brauner
2024-12-05 15:06 ` Mateusz Guzik
2024-08-08 13:20 ` Christian Brauner [this message]
2024-08-08 16:11 ` [RFC] why do we need smp_rmb/smp_wmb pair in fd_install()/expand_fdtable()? Linus Torvalds
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=20240808-dates-pechschwarz-0cccfed2c605@brauner \
--to=brauner@kernel.org \
--cc=edumazet@google.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=mjguzik@gmail.com \
--cc=paulmck@kernel.org \
--cc=torvalds@linux-foundation.org \
--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.