From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: Re: [PATCH 1/4] KVM: Add APIs for unlocked TLB flush Date: Tue, 8 May 2012 10:50:18 -0300 Message-ID: <20120508135018.GA4479@amt.cnet> References: <1336044182-12023-1-git-send-email-avi@redhat.com> <1336044182-12023-2-git-send-email-avi@redhat.com> <4FA286BD.2020009@linux.vnet.ibm.com> <4FA291F5.4090408@redhat.com> <4FA77464.4080300@linux.vnet.ibm.com> <4FA780C8.5050900@redhat.com> <20120508015515.GA26590@amt.cnet> <4FA8E2D2.6000600@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Xiao Guangrong , kvm@vger.kernel.org, takuya.yoshikawa@gmail.com To: Avi Kivity Return-path: Received: from mx1.redhat.com ([209.132.183.28]:46739 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754991Ab2EHO5Y (ORCPT ); Tue, 8 May 2012 10:57:24 -0400 Content-Disposition: inline In-Reply-To: <4FA8E2D2.6000600@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Tue, May 08, 2012 at 12:09:38PM +0300, Avi Kivity wrote: > On 05/08/2012 04:55 AM, Marcelo Tosatti wrote: > > > > Yes, so, we can change kvm_mark_tlb_dirty to: > > > > > > > > +static inline void kvm_mark_tlb_dirty(struct kvm *kvm) > > > > +{ > > > > + /* > > > > + * Make any changes to the page tables visible to remote flushers. > > > > + */ > > > > + smb_mb(); > > > > + kvm->tlb_state.dirtied_count++; > > > > +} > > > > > > > > > > Yes. We'll have to change it again if we ever dirty sptes outside the > > > lock, but that's okay. > > > > Please don't. There are readers outside mmu_lock, so it should be > > atomic. > > Why does it need to be atomic? All it needs is to be properly barriered > (provided by spin_unlock(mmu_lock). It does not _need_ to be atomic. It is easier to verify and self contained.