From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gui Jianfeng Subject: Re: [PATCH] kvm mmu: optimizations when tdp is in use Date: Fri, 28 May 2010 08:24:38 +0800 Message-ID: <4BFF0D46.2000204@cn.fujitsu.com> References: <4BFE280A.3090607@cn.fujitsu.com> <20100527124032.GA30250@amt.cnet> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: Avi Kivity , kvm@vger.kernel.org To: Marcelo Tosatti Return-path: Received: from cn.fujitsu.com ([222.73.24.84]:62490 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1753662Ab0E1A0k (ORCPT ); Thu, 27 May 2010 20:26:40 -0400 In-Reply-To: <20100527124032.GA30250@amt.cnet> Sender: kvm-owner@vger.kernel.org List-ID: Marcelo Tosatti wrote: > On Thu, May 27, 2010 at 04:06:34PM +0800, Gui Jianfeng wrote: >> In case of using tdp, checking write protected page isn't needed and >> quadrant also no need to be calculated. >> >> Signed-off-by: Gui Jianfeng >> --- >> arch/x86/kvm/mmu.c | 7 +++++-- >> 1 files changed, 5 insertions(+), 2 deletions(-) >> >> diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c >> index 0bb9f17..ce4bbd3 100644 >> --- a/arch/x86/kvm/mmu.c >> +++ b/arch/x86/kvm/mmu.c >> @@ -495,10 +495,13 @@ static int mapping_level(struct kvm_vcpu *vcpu, gfn_t large_gfn) >> max_level = kvm_x86_ops->get_lpage_level() < host_level ? >> kvm_x86_ops->get_lpage_level() : host_level; >> >> + if (tdp_enabled) >> + goto done; >> + > > This is wrong. write_count is initialized for alignment purposes, not > only write protected pages. See __kvm_set_memory_region in > virt/kvm/kvm_main.c. thanks, avi also pointed this out. Gui > >> for (level = PT_DIRECTORY_LEVEL; level <= max_level; ++level) >> if (has_wrprotected_page(vcpu->kvm, large_gfn, level)) >> break; >> - >> +done: >> return level - 1; >> } >> >> @@ -1346,7 +1349,7 @@ static struct kvm_mmu_page *kvm_mmu_get_page(struct kvm_vcpu *vcpu, >> if (role.direct) >> role.cr4_pae = 0; >> role.access = access; >> - if (vcpu->arch.mmu.root_level <= PT32_ROOT_LEVEL) { >> + if (!tdp_enabled && vcpu->arch.mmu.root_level <= PT32_ROOT_LEVEL) { >> quadrant = gaddr >> (PAGE_SHIFT + (PT64_PT_BITS * level)); >> quadrant &= (1 << ((PT32_PT_BITS - PT64_PT_BITS) * level)) - 1; >> role.quadrant = quadrant; >> -- >> 1.6.5.2 >> -- >> To unsubscribe from this list: send the line "unsubscribe kvm" in >> the body of a message to majordomo@vger.kernel.org >> More majordomo info at http://vger.kernel.org/majordomo-info.html > > -- Regards Gui Jianfeng