Re: [PATCH 0/5] Fix improper uses of smp_mb__{before,after}_atomic()

From: Peter Zijlstra
Date: Tue Apr 30 2019 - 04:34:38 EST


On Mon, Apr 29, 2019 at 10:14:56PM +0200, Andrea Parri wrote:
> Hello!
>
> A relatively common misuse of these barriers is to apply these to
> operations which are not read-modify-write operations, such as
> atomic_set() and atomic_read(); examples were discussed in [1].
>
> This series attempts to fix those uses by (conservatively) replacing
> the smp_mb__{before,after}_atomic() barriers with full memory barriers.

I don't think blindly doing this replacement makes the code any better;
much of the code you found is just straight up dodgy to begin with.

I think the people should mostly just consider this a bug report.

Also, remember a memory barrier without a coherent comment is most
likely a bug anyway.