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.txt says

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

2013-10-31 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 practice

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, but

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 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(). Unsurprisingly, the

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't have

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 practice

[PATCH RFC] kvm: optimize out smp_mb using srcu_read_unlock

2013-10-30 Thread Michael S. Tsirkin
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: before vmcall 1407 after vmcall 1357

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

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 empty macro

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 rely on this? If