On Mon, Oct 25, 2021 at 10:33 AM Zhang Zeren <zhangzr23@xxxxxxxxx> wrote: > > Hi, I read an example in the Documentation/memory-barriers.txt, which says >> >> (*) On any given CPU, dependent memory accesses will be issued in order, with >> respect to itself. This means that for: "dependent" _is_ the key to understanding this topic. As Valentin Vidić wrote, your loads are _not_ dependent and / or related in any way. > As far as I understand it, linux kernel memory model (LKMM) guarantee two read operations > execute in order. And if the CPU architecture offer an looser memory ordering (like Alpha), then > the compiler must help to add a memory barrier after the load instruction to fufill the LKMM's > standard. No, adding a memory barrier is not a compiler job, instead it is up to the kernel code. For instance, please take a look at the implementation of __READ_ONCE() for Alpha in arch/alpha/include/asm/rwonce.h (note that __READ_ONCE() is used by READ_ONCE()). Regards, Fabio M. De Francesco _______________________________________________ Kernelnewbies mailing list Kernelnewbies@xxxxxxxxxxxxxxxxx https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies