Re: [PATCH] virtio: use smp_load_acquire/smp_store_release

2015-12-17 Thread Michael S. Tsirkin
On Thu, Dec 17, 2015 at 11:58:27AM +0100, Peter Zijlstra wrote: > On Thu, Dec 17, 2015 at 12:29:03PM +0200, Michael S. Tsirkin wrote: > > +static inline __virtio16 virtio_load_acquire(bool weak_barriers, > > __virtio16 *p) > > +{ > > + if (!weak_barriers) { > > + rmb(); > > +

Re: [PATCH] virtio: use smp_load_acquire/smp_store_release

2015-12-17 Thread Peter Zijlstra
On Thu, Dec 17, 2015 at 12:29:03PM +0200, Michael S. Tsirkin wrote: > +static inline __virtio16 virtio_load_acquire(bool weak_barriers, __virtio16 > *p) > +{ > + if (!weak_barriers) { > + rmb(); > + return READ_ONCE(*p); > + } > +#ifdef CONFIG_SMP > + return smp

[PATCH] virtio: use smp_load_acquire/smp_store_release

2015-12-17 Thread Michael S. Tsirkin
virtio ring entries have exactly the acquire/release semantics: - reading used index acquires a ring entry from host - updating the available index releases it to host Thus when using weak barriers and building for SMP (as most people do), smp_load_acquire and smp_store_release wil