On Wed, Mar 02, 2016 at 09:08:31PM +0800, Jianyu Zhan wrote: ...
> 3) READ_ONCE() _might_ prevent more _theoretical_ "optimizations" by the > compiler: > > The above retry logic is effectively the same as: > > while (lock_ptr = READ_ONCE(q->lock_ptr)) { > spin_lock(lock_ptr) The spin_lock() is memory barrier, and therefor a general compiler barrier. The READ_ONCE would be redundant in this case. Unless you can demonstrate a failure mode in disassembly, or can point out how the spin_lock barrier is insufficient that I have missed, this third point is already covered. -- Darren Hart Intel Open Source Technology Center