From: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
To: Avi Kivity <avi@redhat.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>,
LKML <linux-kernel@vger.kernel.org>, KVM <kvm@vger.kernel.org>
Subject: [PATCH 2/2] KVM: MMU: optimize pte write path if don't have protected sp
Date: Mon, 28 Mar 2011 10:30:42 +0800 [thread overview]
Message-ID: <4D8FF2D2.9070109@cn.fujitsu.com> (raw)
In-Reply-To: <4D8FF287.1040300@cn.fujitsu.com>
Simplely return from kvm_mmu_pte_write path if no shadow page is
write-protected, than we can avoid to walk all shadow pages and hold
mmu-lock
Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
---
arch/x86/kvm/mmu.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
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);
--
1.7.4
next prev parent reply other threads:[~2011-03-28 2:29 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-28 2:29 [PATCH 1/2] KVM: MMU: remove mmu_seq verification on pte write path Xiao Guangrong
2011-03-28 2:30 ` Xiao Guangrong [this message]
2011-04-05 8:34 ` [PATCH 2/2] KVM: MMU: optimize pte write path if don't have protected sp Avi Kivity
2011-04-05 8:35 ` [PATCH 1/2] KVM: MMU: remove mmu_seq verification on pte write path Avi Kivity
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4D8FF2D2.9070109@cn.fujitsu.com \
--to=xiaoguangrong@cn.fujitsu.com \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mtosatti@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox