]> err.no Git - linux-2.6/commitdiff
KVM: MMU: Coalesce remote tlb flushes
authorEddie Dong <eddie.dong@intel.com>
Mon, 17 Dec 2007 22:08:27 +0000 (06:08 +0800)
committerAvi Kivity <avi@qumranet.com>
Wed, 30 Jan 2008 16:01:19 +0000 (18:01 +0200)
Host side TLB flush can be merged together if multiple
spte need to be write-protected.

Signed-off-by: Yaozu (Eddie) Dong <eddie.dong@intel.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
arch/x86/kvm/mmu.c

index 401eb7ce32077130a81b89122c53d22da18a9aa6..9a57e1a0144931010f3bd85e984209e010852552 100644 (file)
@@ -513,6 +513,7 @@ static void rmap_write_protect(struct kvm *kvm, u64 gfn)
 {
        unsigned long *rmapp;
        u64 *spte;
+       int write_protected = 0;
 
        gfn = unalias_gfn(kvm, gfn);
        rmapp = gfn_to_rmap(kvm, gfn);
@@ -522,11 +523,14 @@ static void rmap_write_protect(struct kvm *kvm, u64 gfn)
                BUG_ON(!spte);
                BUG_ON(!(*spte & PT_PRESENT_MASK));
                rmap_printk("rmap_write_protect: spte %p %llx\n", spte, *spte);
-               if (is_writeble_pte(*spte))
+               if (is_writeble_pte(*spte)) {
                        set_shadow_pte(spte, *spte & ~PT_WRITABLE_MASK);
-               kvm_flush_remote_tlbs(kvm);
+                       write_protected = 1;
+               }
                spte = rmap_next(kvm, rmapp, spte);
        }
+       if (write_protected)
+               kvm_flush_remote_tlbs(kvm);
 }
 
 #ifdef MMU_DEBUG