Re: [PATCH] fs: add memory barrier in __fget_light()

From: Linus Torvalds
Date: Mon Oct 31 2022 - 13:37:28 EST


On Mon, Oct 31, 2022 at 10:13 AM Jann Horn <jannh@xxxxxxxxxx> 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()".

Much better on sane architectures.

Linus