From: Anthony Yznaga Date: Tue, 2 Jun 2020 20:07:29 +0000 (-0700) Subject: KVM: x86: avoid unnecessary rmap walks when creating/moving slots X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=4b44295538b421de2de8b5754472284fe2daa4e9;p=linux.git KVM: x86: avoid unnecessary rmap walks when creating/moving slots On large memory guests it has been observed that creating a memslot for a very large range can take noticeable amount of time. Investigation showed that the time is spent walking the rmaps to update existing sptes to remove write access or set/clear dirty bits to support dirty logging. These rmap walks are unnecessary when creating or moving a memslot. A newly created memslot will not have any existing mappings, and the existing mappings of a moved memslot will have been invalidated and flushed. Any mappings established once the new/moved memslot becomes visible will be set using the properties of the new slot. Signed-off-by: Anthony Yznaga Message-Id: <1591128450-11977-3-git-send-email-anthony.yznaga@oracle.com> Signed-off-by: Paolo Bonzini --- diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index e11e0494f833a..f39bdd5fd7cf1 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -10242,7 +10242,7 @@ void kvm_arch_commit_memory_region(struct kvm *kvm, * * FIXME: const-ify all uses of struct kvm_memory_slot. */ - if (change != KVM_MR_DELETE) + if (change == KVM_MR_FLAGS_ONLY) kvm_mmu_slot_apply_flags(kvm, (struct kvm_memory_slot *) new); /* Free the arrays associated with the old memslot. */