From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: Re: [PATCH v3 07/15] KVM: MMU: introduce nulls desc Date: Tue, 26 Nov 2013 17:31:48 -0200 Message-ID: <20131126193148.GA18071@amt.cnet> References: <1382534973-13197-1-git-send-email-xiaoguangrong@linux.vnet.ibm.com> <1382534973-13197-8-git-send-email-xiaoguangrong@linux.vnet.ibm.com> <20131122191429.GA13308@amt.cnet> <65EE805B-B5DB-4BD0-A057-E5FF78D96D67@linux.vnet.ibm.com> <5292EE2F.5090305@linux.vnet.ibm.com> <20131125181254.GB21858@amt.cnet> <529413C1.60302@linux.vnet.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: Gleb Natapov , avi.kivity@gmail.com, "pbonzini@redhat.com Bonzini" , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Eric Dumazet , Peter Zijlstra To: Xiao Guangrong Return-path: Content-Disposition: inline In-Reply-To: <529413C1.60302@linux.vnet.ibm.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On Tue, Nov 26, 2013 at 11:21:37AM +0800, Xiao Guangrong wrote: > On 11/26/2013 02:12 AM, Marcelo Tosatti wrote: > > On Mon, Nov 25, 2013 at 02:29:03PM +0800, Xiao Guangrong wrote: > >>>> Also, there is no guarantee of termination (as long as sptes are > >>>> deleted with the correct timing). BTW, can't see any guarantee o= f > >>>> termination for rculist nulls either (a writer can race with a l= ockless > >>>> reader indefinately, restarting the lockless walk every time). > >>> > >>> Hmm, that can be avoided by checking dirty-bitmap before rewalk, > >>> that means, if the dirty-bitmap has been set during lockless writ= e-protection, > >>> it=EF=BF=BDs unnecessary to write-protect its sptes. Your idea? > >> This idea is based on the fact that the number of rmap is limited = by > >> RMAP_RECYCLE_THRESHOLD. So, in the case of adding new spte into rm= ap, > >> we can break the rewalk at once, in the case of deleting, we can o= nly > >> rewalk RMAP_RECYCLE_THRESHOLD times. > >=20 > > Please explain in more detail. >=20 > Okay. >=20 > My proposal is like this: >=20 > pte_list_walk_lockless() > { > restart: >=20 > + if (__test_bit(slot->arch.dirty_bitmap, gfn-index)) > + return; >=20 > code-doing-lockless-walking; > ...... > } >=20 > Before do lockless-walking, we check the dirty-bitmap first, if > it is set we can simply skip write-protection for the gfn, that > is the case that new spte is being added into rmap when we lockless > access the rmap. The dirty bit could be set after the check. > For the case of deleting spte from rmap, the number of entry is limit= ed > by RMAP_RECYCLE_THRESHOLD, that is not endlessly. It can shrink and grow while lockless walk is performed.