On Sat, Aug 17, 2024 at 9:25 AM David Howells <dhowells@xxxxxxxxxx> wrote: > > Mateusz Guzik <mjguzik@xxxxxxxxx> wrote: > > > ... atomic_read and atomic_set -- these merely expand to regular movs, ... > > Ah, no, that's not necessarily true. See arch/parisc/include/asm/atomic.h. > In that context I was talking about amd64. atomic_read/set do happen to provide some fencing on some archs, but there are no guarantees as far as LKMM is concerned -- for example atomic_read is explicitly documented to only provide relaxed ordering (aka no guarantees). In particular on amd64 the full memory barrier normally coming with lock-prefixed instructions (and xchg with a memory operand) is not present here because this merely expands to a regular mov, making the code bogus if such a fence is indeed required in this code. -- Mateusz Guzik <mjguzik gmail.com>