Skip to content

Commit 6ba1e04

Browse files
shvipinbonzini
authored andcommitted
KVM: x86/mmu: Speed up slot_rmap_walk_next for sparsely populated rmaps
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>
1 parent 3c5c324 commit 6ba1e04

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

arch/x86/kvm/mmu/mmu.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,9 +1483,11 @@ static bool slot_rmap_walk_okay(struct slot_rmap_walk_iterator *iterator)
14831483

14841484
static void slot_rmap_walk_next(struct slot_rmap_walk_iterator *iterator)
14851485
{
1486-
if (++iterator->rmap <= iterator->end_rmap) {
1486+
while (++iterator->rmap <= iterator->end_rmap) {
14871487
iterator->gfn += (1UL << KVM_HPAGE_GFN_SHIFT(iterator->level));
1488-
return;
1488+
1489+
if (iterator->rmap->val)
1490+
return;
14891491
}
14901492

14911493
if (++iterator->level > iterator->end_level) {

0 commit comments

Comments
 (0)