KVM: Use interval tree to do fast hva lookup in memslots
authorMaciej S. Szmigiero <maciej.szmigiero@oracle.com>
Mon, 6 Dec 2021 19:54:28 +0000 (20:54 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 8 Dec 2021 09:24:32 +0000 (04:24 -0500)
commited922739c9199bf515a3e7fec3e319ce1edeef2a
tree287fba29b9f4f72147c4db889723274e3e7269f1
parent26b8345abc75a7404716864710930407b7d873f9
KVM: Use interval tree to do fast hva lookup in memslots

The current memslots implementation only allows quick binary search by gfn,
quick lookup by hva is not possible - the implementation has to do a linear
scan of the whole memslots array, even though the operation being performed
might apply just to a single memslot.

This significantly hurts performance of per-hva operations with higher
memslot counts.

Since hva ranges can overlap between memslots an interval tree is needed
for tracking them.

[sean: handle interval tree updates in kvm_replace_memslot()]
Signed-off-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>
Message-Id: <d66b9974becaa9839be9c4e1a5de97b177b4ac20.1638817640.git.maciej.szmigiero@oracle.com>
arch/arm64/kvm/Kconfig
arch/mips/kvm/Kconfig
arch/powerpc/kvm/Kconfig
arch/s390/kvm/Kconfig
arch/x86/kvm/Kconfig
include/linux/kvm_host.h
virt/kvm/kvm_main.c