On 20.07.2020 17:28, Andrew Cooper wrote: > On 16/07/2020 11:06, Jan Beulich wrote: >> ACCESS_ONCE() guarantees single access, but doesn't guarantee that >> the compiler wouldn't split this single access into multiple insns. > > ACCESS_ONCE() does guarantee single accesses for any natural integer size. > > There is a section about this specifically in Linux's > memory-barriers.txt, and this isn't the first time I've pointed it out...
There indeed is text stating this, but I can't find any word on why they believe this is the case. My understanding of volatile is that it guarantees no more (and also no less) accesses to any single storage location than indicated by the source. But it doesn't prevent "tearing" of accesses. And really, how could it, considering that volatile can also be applied to types that aren't basic ones, and hence in particular to ones that can't possibly be accessed by a single insn? I'd be glad to see you point out the aspect I'm missing here. Jan