Paolo Bonzini <[email protected]> writes: > On 24/09/2016 22:43, Richard Henderson wrote: >>>> I don't see that the cpu_list_lock protects the >>>> last two lines in any way. >>> >>> It does: >>> >>> qemu_mutex_lock(&qemu_cpu_list_lock); >> >> What I meant is that I don't see that the mutex avoids the need for >> atomic_set. > > Oh, I see. > > cpu->running is only read under the mutex, but can be written _by the > owner thread only_ outside the mutex. So writes outside the mutex must > be atomic, but writes under the mutex don't because: > > - no other thread ever writes to cpu->running > > - no other thread can be reading cpu->running
Should we add some comments to cpu.h's definitions to make the rules clear? -- Alex Bennée
