[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <Y2D6lbcp8Mxwu6A5@FVFF77S0Q05N>
Date: Tue, 1 Nov 2022 10:53:20 +0000
From: Mark Rutland <mark.rutland@....com>
To: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Jann Horn <jannh@...gle.com>, Al Viro <viro@...iv.linux.org.uk>,
Miklos Szeredi <mszeredi@...hat.com>,
linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org,
Will Deacon <will@...nel.org>
Subject: Re: [PATCH] fs: add memory barrier in __fget_light()
On Mon, Oct 31, 2022 at 10:37:01AM -0700, Linus Torvalds wrote:
> On Mon, Oct 31, 2022 at 10:13 AM Jann Horn <jannh@...gle.com> wrote:
> >
> > If this is too expensive on platforms like arm64, I guess the more
> > performant alternative would be to add another flags field that tracks
> > whether the fs_struct was ever shared and check that instead of the
> > reference count in __fget_light().
>
> No, the problem is that you should never use the "smp_*mb()" horrors
> for any new code.
>
> All the "smp_*mb()" things really are broken. Please consider them
> legacy garbage. It was how people though about SMP memory ordering in
> the bad old days.
>
> So get with the 21st century, and instead replace the "atomic_read()"
> with a "smp_load_acquire()".
Minor nit: atomic{,64,_long}_{read_acquire,set_release}() exist to be used
directly on atomics and should d.t.r.t. on all architectures (e.g. where 64-bit
atomics on 32-bit platforms have extra requirements).
So this instance can be:
...
if (atomic_read_acquire(&files->count) == 1) {
...
Mark.
Powered by blists - more mailing lists