Re: [PATCH RFC] kvm: optimize out smp_mb using srcu_read_unlock

2013-11-01 Thread Paul E. McKenney
On Thu, Oct 31, 2013 at 03:57:14PM +0200, Michael S. Tsirkin wrote: > On Wed, Oct 30, 2013 at 09:56:29PM -0700, Paul E. McKenney wrote: > > On Thu, Oct 31, 2013 at 01:26:05AM +0200, Michael S. Tsirkin wrote: > > > > > Paul, could you review this patch please? > > > > > Documentation/memory-barriers

Re: [PATCH RFC] kvm: optimize out smp_mb using srcu_read_unlock

2013-10-31 Thread Michael S. Tsirkin
On Wed, Oct 30, 2013 at 09:56:29PM -0700, Paul E. McKenney wrote: > On Thu, Oct 31, 2013 at 01:26:05AM +0200, Michael S. Tsirkin wrote: > > > > Paul, could you review this patch please? > > > > Documentation/memory-barriers.txt says that unlock has a weaker > > > > uni-directional barrier, but in p

Re: [PATCH RFC] kvm: optimize out smp_mb using srcu_read_unlock

2013-10-31 Thread Gleb Natapov
On Thu, Oct 31, 2013 at 12:11:21PM +0100, Paolo Bonzini wrote: > Il 31/10/2013 07:47, Gleb Natapov ha scritto: > > This looks dubious to me. All other smp_mb__after_* variants are there > > because some atomic operations have different memory barrier semantics on > > different arches, > > It doesn

Re: [PATCH RFC] kvm: optimize out smp_mb using srcu_read_unlock

2013-10-31 Thread Michael S. Tsirkin
On Thu, Oct 31, 2013 at 12:14:15PM +0100, Paolo Bonzini wrote: > Il 30/10/2013 20:09, Michael S. Tsirkin ha scritto: > > I noticed that srcu_read_lock/unlock both have a memory barrier, > > so just by moving srcu_read_unlock earlier we can get rid of > > one call to smp_mb(). > > > > Unsurprisingl

Re: [PATCH RFC] kvm: optimize out smp_mb using srcu_read_unlock

2013-10-31 Thread Paolo Bonzini
Il 30/10/2013 20:09, Michael S. Tsirkin ha scritto: > I noticed that srcu_read_lock/unlock both have a memory barrier, > so just by moving srcu_read_unlock earlier we can get rid of > one call to smp_mb(). > > Unsurprisingly, the gain is small but measureable using the unit test > microbenchmark:

Re: [PATCH RFC] kvm: optimize out smp_mb using srcu_read_unlock

2013-10-31 Thread Paolo Bonzini
Il 31/10/2013 07:47, Gleb Natapov ha scritto: > This looks dubious to me. All other smp_mb__after_* variants are there > because some atomic operations have different memory barrier semantics on > different arches, It doesn't have to be arches; unlock APIs typically have release semantics only, bu

Re: [PATCH RFC] kvm: optimize out smp_mb using srcu_read_unlock

2013-10-30 Thread Gleb Natapov
On Wed, Oct 30, 2013 at 09:56:29PM -0700, Paul E. McKenney wrote: > On Thu, Oct 31, 2013 at 01:26:05AM +0200, Michael S. Tsirkin wrote: > > > > Paul, could you review this patch please? > > > > Documentation/memory-barriers.txt says that unlock has a weaker > > > > uni-directional barrier, but in p

Re: [PATCH RFC] kvm: optimize out smp_mb using srcu_read_unlock

2013-10-30 Thread Paul E. McKenney
On Thu, Oct 31, 2013 at 01:26:05AM +0200, Michael S. Tsirkin wrote: > > > Paul, could you review this patch please? > > > Documentation/memory-barriers.txt says that unlock has a weaker > > > uni-directional barrier, but in practice srcu_read_unlock calls > > > smp_mb(). > > > > > > Is it OK to re

Re: [PATCH RFC] kvm: optimize out smp_mb using srcu_read_unlock

2013-10-30 Thread Michael S. Tsirkin
> > Paul, could you review this patch please? > > Documentation/memory-barriers.txt says that unlock has a weaker > > uni-directional barrier, but in practice srcu_read_unlock calls > > smp_mb(). > > > > Is it OK to rely on this? If not, can I add > > smp_mb__after_srcu_read_unlock (making it an e

Re: [PATCH RFC] kvm: optimize out smp_mb using srcu_read_unlock

2013-10-30 Thread Paul E. McKenney
On Wed, Oct 30, 2013 at 09:09:29PM +0200, Michael S. Tsirkin wrote: > I noticed that srcu_read_lock/unlock both have a memory barrier, > so just by moving srcu_read_unlock earlier we can get rid of > one call to smp_mb(). > > Unsurprisingly, the gain is small but measureable using the unit test >