From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: Re: [PATCH] kvm mmu: reduce 50% memory usage Date: Wed, 28 Apr 2010 15:05:03 -0300 Message-ID: <20100428180503.GJ18168@amt.cnet> References: <4BD8228D.7090708@cn.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Avi Kivity , LKML , kvm@vger.kernel.org To: Lai Jiangshan Return-path: Received: from mx1.redhat.com ([209.132.183.28]:22676 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755014Ab0D1SFX (ORCPT ); Wed, 28 Apr 2010 14:05:23 -0400 Content-Disposition: inline In-Reply-To: <4BD8228D.7090708@cn.fujitsu.com> Sender: kvm-owner@vger.kernel.org List-ID: On Wed, Apr 28, 2010 at 07:57:01PM +0800, Lai Jiangshan wrote: > > I think users will enable tdp when their hardwares support ept or npt. > This patch can reduce about 50% kvm mmu memory usage for they. > > This simple patch use the fact that: > > When sp->role.direct is set, sp->gfns does not contain any essential > information, leaf sptes reachable from this sp are for a continuate > guest physical memory range(a linear range). > So sp->gfns[i](if it was set) equals to sp->gfn + i. (PT_PAGE_TABLE_LEVEL) > Obviously, it is not essential information, we can calculate it when need. > > It means we don't need sp->gfns when sp->role.direct=1, > Thus we can save one page usage for every kvm_mmu_page. > > Note: > Access to sp->gfns must be wrapped by kvm_mmu_page_get_gfn() > or kvm_mmu_page_set_gfn(). > It is only exposed in FNAME(sync_page). > > Signed-off-by: Lai Jiangshan Applied, thanks.