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: Mon, 25 Nov 2013 12:08:03 -0200 Message-ID: <20131125140803.GA1489@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> 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: <65EE805B-B5DB-4BD0-A057-E5FF78D96D67@linux.vnet.ibm.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On Mon, Nov 25, 2013 at 02:11:31PM +0800, Xiao Guangrong wrote: >=20 > On Nov 23, 2013, at 3:14 AM, Marcelo Tosatti wr= ote: >=20 > > On Wed, Oct 23, 2013 at 09:29:25PM +0800, Xiao Guangrong wrote: > >> It likes nulls list and we use the pte-list as the nulls which can= help us to > >> detect whether the "desc" is moved to anther rmap then we can re-w= alk the rmap > >> if that happened > >>=20 > >> kvm->slots_lock is held when we do lockless walking that prevents = rmap > >> is reused (free rmap need to hold that lock) so that we can not se= e the same > >> nulls used on different rmaps > >>=20 > >> Signed-off-by: Xiao Guangrong > >=20 > > How about simplified lockless walk on the slot while rmapp entry > > contains a single spte? (which should be the case with two-dimensio= nal > > paging). > >=20 > > That is, grab the lock when finding a rmap with more than one spte = in > > it (and then keep it locked until the end). >=20 > Hmm=E2=80=A6 that isn't straightforward and more complex than the app= roach > in this patchset. Also it can drop the improvement for shadow mmu tha= t > gets great improvement by this patchset. It is not more complex, since it would remove list lockless walk. Only the spte pointer at rmap[spte] is accessed without a lock. Its much muc= h simpler. > > For example, nothing prevents lockless walker to move into some > > parent_ptes chain, right? >=20 > No. >=20 > The nulls can help us to detect this case, for parent_ptes, the nulls= points > to "shadow page" but for rmaps, the nulls points to slot.arch.rmap. T= here > is no chance that the =E2=80=9Crmap" is used as shadow page when slot= -lock is held. The SLAB cache is the same, so entries can be reused. What prevents a desc entry living in slot.arch.rmap to be freed and reused by a parent_ptes desc? > > Also, there is no guarantee of termination (as long as sptes are > > deleted with the correct timing). BTW, can't see any guarantee of > > termination for rculist nulls either (a writer can race with a lock= less > > reader indefinately, restarting the lockless walk every time). >=20 > Hmm, that can be avoided by checking dirty-bitmap before rewalk, > that means, if the dirty-bitmap has been set during lockless write-pr= otection, > it=E2=80=99s unnecessary to write-protect its sptes. Your idea? >=20 > But=E2=80=A6 do we really need to care it. :( See my reply to Avi.