]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
KVM: x86/mmu: Speed up slot_rmap_walk_next for sparsely populated rmaps
authorVipin Sharma <vipinsh@google.com>
Mon, 2 May 2022 22:03:47 +0000 (22:03 +0000)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 12 May 2022 13:51:45 +0000 (09:51 -0400)
Avoid calling handlers on empty rmap entries and skip to the next non
empty rmap entry.

Empty rmap entries are noop in handlers.

Signed-off-by: Vipin Sharma <vipinsh@google.com>
Suggested-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20220502220347.174664-1-vipinsh@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/mmu/mmu.c

index ea4bc085bbf5bf29babe4b47c9e5a5a381288bd1..efe5a3dca1e092e89dfcde77c8df65d4a5befcde 100644 (file)
@@ -1483,9 +1483,11 @@ static bool slot_rmap_walk_okay(struct slot_rmap_walk_iterator *iterator)
 
 static void slot_rmap_walk_next(struct slot_rmap_walk_iterator *iterator)
 {
-       if (++iterator->rmap <= iterator->end_rmap) {
+       while (++iterator->rmap <= iterator->end_rmap) {
                iterator->gfn += (1UL << KVM_HPAGE_GFN_SHIFT(iterator->level));
-               return;
+
+               if (iterator->rmap->val)
+                       return;
        }
 
        if (++iterator->level > iterator->end_level) {