On 03/10/2018 17:48, Emilio G. Cota wrote: >> it's probably best to do all atomic_set instead of just the memberwise copy. > Atomics aren't necessary here, as long as the copy is protected by the > lock. This allows other vCPUs to see a consistent view of the data (since > they always acquire the TLB lock), and since copy_tlb is only called > by the vCPU that owns the TLB, regular reads from this vCPU will always > see consistent data.
For reads I agree, but you may actually get a torn read if the writer doesn't use atomic_set. That's because in order to avoid UB all reads or writes that are concurrent with another write must be atomic, and the write must be atomic too. The lock does prevent write-write concurrent accesses, but not read-write, so the write must be atomic here. Paolo