On Fri, Apr 07, 2017 at 11:33:33PM +0800, Paolo Bonzini wrote: > > > On 06/04/2017 23:08, Andrew Jones wrote: > > My own made-up lingo to state that each time the variable is accessed it > > must be loaded anew, taken care of by the volatile use in READ_ONCE. As > > vcpu->requests can be written by other threads, then I prefer READ_ONCE > > being used to read it, as it allows me to avoid spending energy convincing > > myself that the compiler would have emitted a load at that point anyway. > > Also, READ_ONCE without a barrier is really fishy unless it's > > while (READ_ONCE(x) != 2) { > ... > } > > or similar, and WRITE_ONCE doesn't even have this exception. So > annotating variables accessed by multiple threads with > READ_ONCE/WRITE_ONCE is generally a good idea. > I'm sorry, I'm confused. You're saying that it's fishy to use READ_ONCE() without also having a barrier, but does that imply that if you have a barrier, you should also have READ_ONCE() ? In any case, as I hope I've made clear, I'm perfectly fine with having READ_ONCE(), as long as we make a best effort attempt at describing why we added it, so even I can understand that later - in the code directly or in the commit message. Thanks, -Christoffer