[PATCH 5/8] KVM: MMU: optimize walking unsync shadow page

From: Xiao Guangrong
Date: Fri Dec 16 2011 - 05:17:09 EST


Exactly, unysnc_children is the number of unsync sptes, we can use to
avoid unnecessary spte fetching

Signed-off-by: Xiao Guangrong <xiaoguangrong@xxxxxxxxxxxxxxxxxx>
---
arch/x86/kvm/mmu.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 9bd2084..16e0642 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -1468,12 +1468,15 @@ static int __mmu_unsync_walk(struct kvm_mmu_page *sp,
struct kvm_mmu_pages *pvec)
{
u64 *spte;
- int i, ret, nr_unsync_leaf = 0;
+ int i, ret, nr_unsync_leaf = 0, unysnc_children = sp->unsync_children;

for_each_unsync_children(sp, spte, i) {
struct kvm_mmu_page *child;
u64 ent = *spte;

+ if (!unysnc_children--)
+ break;
+
WARN_ON(!is_shadow_present_pte(ent) || is_large_pte(ent));

child = page_header(ent & PT64_BASE_ADDR_MASK);
--
1.7.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/