Re: [PATCH] KVM: Remove redundant smp_mb() in the kvm_mmu_commit_zap_page()

2016-03-10 Thread Lan Tianyu
On 2016年03月10日 23:26, Paolo Bonzini wrote: > > > On 10/03/2016 15:40, Xiao Guangrong wrote: >> long dirty_count = kvm->tlbs_dirty; >> >> +/* >> + * read tlbs_dirty before doing tlb flush to make sure not tlb >> request is >> + * lost. >> + */ >> smp_mb();

Re: [PATCH] KVM: Remove redundant smp_mb() in the kvm_mmu_commit_zap_page()

2016-03-10 Thread Xiao Guangrong
On 03/11/2016 01:07 AM, Paolo Bonzini wrote: On 09/03/2016 08:18, Lan Tianyu wrote: How about the following comments. Log for kvm_mmu_commit_zap_page() /* * We need to make sure everyone sees our modifications to * the page tables and see changes to vcpu->mode here.

Re: [PATCH] KVM: Remove redundant smp_mb() in the kvm_mmu_commit_zap_page()

2016-03-10 Thread Xiao Guangrong
On 03/11/2016 12:04 AM, Paolo Bonzini wrote: On 10/03/2016 16:45, Xiao Guangrong wrote: Compared to smp_load_acquire(), smp_mb() adds an ordering between stores and loads. Here, the ordering is load-store, hence... Yes, this is why i put smp_mb() in the code. :) Here is a table of ba

Re: [PATCH] KVM: Remove redundant smp_mb() in the kvm_mmu_commit_zap_page()

2016-03-10 Thread Paolo Bonzini
On 09/03/2016 08:18, Lan Tianyu wrote: > How about the following comments. > > Log for kvm_mmu_commit_zap_page() > /* >* We need to make sure everyone sees our modifications to >* the page tables and see changes to vcpu->mode here. Please mention that this pairs with vcpu_en

Re: [PATCH] KVM: Remove redundant smp_mb() in the kvm_mmu_commit_zap_page()

2016-03-10 Thread Paolo Bonzini
On 10/03/2016 16:45, Xiao Guangrong wrote: >> >>> Compared to smp_load_acquire(), smp_mb() adds an ordering between stores >>> and loads. >> >> Here, the ordering is load-store, hence... > > Yes, this is why i put smp_mb() in the code. :) Here is a table of barriers: '. after|

Re: [PATCH] KVM: Remove redundant smp_mb() in the kvm_mmu_commit_zap_page()

2016-03-10 Thread Xiao Guangrong
On 03/10/2016 11:31 PM, Paolo Bonzini wrote: On 10/03/2016 16:26, Paolo Bonzini wrote: Compared to smp_load_acquire(), smp_mb() adds an ordering between stores and loads. Here, the ordering is load-store, hence... Yes, this is why i put smp_mb() in the code. :)

Re: [PATCH] KVM: Remove redundant smp_mb() in the kvm_mmu_commit_zap_page()

2016-03-10 Thread Paolo Bonzini
On 10/03/2016 16:26, Paolo Bonzini wrote: > Compared to smp_load_acquire(), smp_mb() adds an ordering between stores > and loads. Here, the ordering is load-store, hence... > The load of kvm->tlbs_dirty should then be > > /* >* Read tlbs_dirty before setting KVM_REQ_TLB_FLUSH in

Re: [PATCH] KVM: Remove redundant smp_mb() in the kvm_mmu_commit_zap_page()

2016-03-10 Thread Paolo Bonzini
On 10/03/2016 15:40, Xiao Guangrong wrote: > long dirty_count = kvm->tlbs_dirty; > > +/* > + * read tlbs_dirty before doing tlb flush to make sure not tlb > request is > + * lost. > + */ > smp_mb(); > + > if (kvm_make_all_cpus_request(kvm, KVM_REQ_T

Re: [PATCH] KVM: Remove redundant smp_mb() in the kvm_mmu_commit_zap_page()

2016-03-10 Thread Xiao Guangrong
On 03/08/2016 11:27 PM, Paolo Bonzini wrote: On 08/03/2016 09:36, Lan Tianyu wrote: Summary about smp_mb()s we met in this thread. If misunderstood, please correct me. Thanks. The smp_mb() in the kvm_flush_remote_tlbs() was introduced by the commit a4ee1ca4 and it seems to keep the order of

Re: [PATCH] KVM: Remove redundant smp_mb() in the kvm_mmu_commit_zap_page()

2016-03-08 Thread Lan Tianyu
On 2016年03月08日 23:27, Paolo Bonzini wrote: > Unfortunately that patch added a bad memory barrier: 1) it lacks a > comment; 2) it lacks obvious pairing; 3) it is an smp_mb() after a read, > so it's not even obvious that this memory barrier has to do with the > immediately preceding read of kvm->tlbs

Re: [PATCH] KVM: Remove redundant smp_mb() in the kvm_mmu_commit_zap_page()

2016-03-08 Thread Paolo Bonzini
On 08/03/2016 09:36, Lan Tianyu wrote: > Summary about smp_mb()s we met in this thread. If misunderstood, please > correct me. Thanks. > > The smp_mb() in the kvm_flush_remote_tlbs() was introduced by the commit > a4ee1ca4 and it seems to keep the order of reading and cmpxchg > kvm->tlbs_dirty.

Re: [PATCH] KVM: Remove redundant smp_mb() in the kvm_mmu_commit_zap_page()

2016-03-08 Thread Lan Tianyu
On 2016年03月04日 16:49, Paolo Bonzini wrote: > On 04/03/2016 08:12, Lan Tianyu wrote: /* - * wmb: make sure everyone sees our modifications to the page tables - * rmb: make sure we see changes to vcpu->mode >>> >>> You want to leave the comment explaining the memory barriers and

Re: [PATCH] KVM: Remove redundant smp_mb() in the kvm_mmu_commit_zap_page()

2016-03-04 Thread Xiao Guangrong
On 03/04/2016 04:04 PM, Paolo Bonzini wrote: On 04/03/2016 02:35, Lan Tianyu wrote: The following kvm_flush_remote_tlbs() will call smp_mb() inside and so remove smp_mb() here. Signed-off-by: Lan Tianyu --- arch/x86/kvm/mmu.c | 6 -- 1 file changed, 6 deletions(-) diff --git a/arch/x

Re: [PATCH] KVM: Remove redundant smp_mb() in the kvm_mmu_commit_zap_page()

2016-03-04 Thread Paolo Bonzini
On 04/03/2016 08:12, Lan Tianyu wrote: > > > /* > > > - * wmb: make sure everyone sees our modifications to the page tables > > > - * rmb: make sure we see changes to vcpu->mode > > > > You want to leave the comment explaining the memory barriers and tell that > > kvm_flush_remote_tlbs() conta

Re: [PATCH] KVM: Remove redundant smp_mb() in the kvm_mmu_commit_zap_page()

2016-03-04 Thread Paolo Bonzini
On 04/03/2016 02:35, Lan Tianyu wrote: > The following kvm_flush_remote_tlbs() will call smp_mb() inside and so > remove smp_mb() here. > > Signed-off-by: Lan Tianyu > --- > arch/x86/kvm/mmu.c | 6 -- > 1 file changed, 6 deletions(-) > > diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c

Re: [PATCH] KVM: Remove redundant smp_mb() in the kvm_mmu_commit_zap_page()

2016-03-03 Thread Lan Tianyu
On 2016年03月04日 15:21, Thomas Gleixner wrote: > On Fri, 4 Mar 2016, Lan Tianyu wrote: > >> The following kvm_flush_remote_tlbs() will call smp_mb() inside and so >> remove smp_mb() here. >> >> Signed-off-by: Lan Tianyu >> --- >> arch/x86/kvm/mmu.c | 6 -- >> 1 file changed, 6 deletions(-) >>

Re: [PATCH] KVM: Remove redundant smp_mb() in the kvm_mmu_commit_zap_page()

2016-03-03 Thread Thomas Gleixner
On Fri, 4 Mar 2016, Lan Tianyu wrote: > The following kvm_flush_remote_tlbs() will call smp_mb() inside and so > remove smp_mb() here. > > Signed-off-by: Lan Tianyu > --- > arch/x86/kvm/mmu.c | 6 -- > 1 file changed, 6 deletions(-) > > diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c