KVM: MMU: reduce KVM_REQ_MMU_RELOAD when root page is zapped
authorGleb Natapov <gleb@redhat.com>
Fri, 31 May 2013 00:36:30 +0000 (08:36 +0800)
committerGleb Natapov <gleb@redhat.com>
Wed, 5 Jun 2013 09:34:02 +0000 (12:34 +0300)
Quote Gleb's mail:
| why don't we check for sp->role.invalid in
| kvm_mmu_prepare_zap_page before calling kvm_reload_remote_mmus()?

and

| Actually we can add check for is_obsolete_sp() there too since
| kvm_mmu_invalidate_all_pages() already calls kvm_reload_remote_mmus()
| after incrementing mmu_valid_gen.

[ Xiao: add some comments and the check of is_obsolete_sp() ]

Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
Reviewed-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Gleb Natapov <gleb@redhat.com>
arch/x86/kvm/mmu.c

index 79af88ab2f1d838bb40ec44703af6de0f38e0281..6941fa74eb352ff6cfffc10140169679cee50556 100644 (file)
@@ -2108,7 +2108,13 @@ static int kvm_mmu_prepare_zap_page(struct kvm *kvm, struct kvm_mmu_page *sp,
                kvm_mod_used_mmu_pages(kvm, -1);
        } else {
                list_move(&sp->link, &kvm->arch.active_mmu_pages);
-               kvm_reload_remote_mmus(kvm);
+
+               /*
+                * The obsolete pages can not be used on any vcpus.
+                * See the comments in kvm_mmu_invalidate_zap_all_pages().
+                */
+               if (!sp->role.invalid && !is_obsolete_sp(kvm, sp))
+                       kvm_reload_remote_mmus(kvm);
        }
 
        sp->role.invalid = 1;