From patchwork Mon Mar 28 02:30:42 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Guangrong X-Patchwork-Id: 667131 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p2S2TsV8029059 for ; Mon, 28 Mar 2011 02:29:54 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753608Ab1C1C3u (ORCPT ); Sun, 27 Mar 2011 22:29:50 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:54502 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1753464Ab1C1C3u (ORCPT ); Sun, 27 Mar 2011 22:29:50 -0400 Received: from tang.cn.fujitsu.com (tang.cn.fujitsu.com [10.167.250.3]) by song.cn.fujitsu.com (Postfix) with ESMTP id DBA2E17013A; Mon, 28 Mar 2011 10:29:47 +0800 (CST) Received: from mailserver.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id p2S2NaAt008824; Mon, 28 Mar 2011 10:23:37 +0800 Received: from eric.localdomain ([10.167.225.99]) by mailserver.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.1FP4) with ESMTP id 2011032810281815-120367 ; Mon, 28 Mar 2011 10:28:18 +0800 Message-ID: <4D8FF2D2.9070109@cn.fujitsu.com> Date: Mon, 28 Mar 2011 10:30:42 +0800 From: Xiao Guangrong User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.15) Gecko/20110307 Fedora/3.1.9-0.39.b3pre.fc14 Thunderbird/3.1.9 MIME-Version: 1.0 To: Avi Kivity CC: Marcelo Tosatti , LKML , KVM Subject: [PATCH 2/2] KVM: MMU: optimize pte write path if don't have protected sp References: <4D8FF287.1040300@cn.fujitsu.com> In-Reply-To: <4D8FF287.1040300@cn.fujitsu.com> X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2011-03-28 10:28:18, Serialize by Router on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2011-03-28 10:28:18, Serialize complete at 2011-03-28 10:28:18 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Mon, 28 Mar 2011 02:29:55 +0000 (UTC) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 2841805..ccac6c4 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -3219,6 +3219,11 @@ static void kvm_mmu_access_page(struct kvm_vcpu *vcpu, gfn_t gfn) set_bit(PT_ACCESSED_SHIFT, (unsigned long *)spte); } +static bool need_track_pte_changed(struct kvm_vcpu *vcpu) +{ + return !tdp_enabled || mmu_is_nested(vcpu); +} + void kvm_mmu_pte_write(struct kvm_vcpu *vcpu, gpa_t gpa, const u8 *new, int bytes, bool guest_initiated) @@ -3233,6 +3238,9 @@ void kvm_mmu_pte_write(struct kvm_vcpu *vcpu, gpa_t gpa, int level, npte, invlpg_counter, r, flooded = 0; bool remote_flush, local_flush, zap_page; + if (!need_track_pte_changed(vcpu)) + return; + zap_page = remote_flush = local_flush = false; offset = offset_in_page(gpa);