OSDN Git Service

KVM: Convert the kvm->vcpus array to a xarray
authorMarc Zyngier <maz@kernel.org>
Tue, 16 Nov 2021 16:04:01 +0000 (16:04 +0000)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 8 Dec 2021 09:24:14 +0000 (04:24 -0500)
commitc5b077549136584618a66258f09d8d4b41e7409c
tree6d8e307d3e7bb7ba976a12f3b235463e9253d31d
parent113d10bca23cdd522da26969b96db8711b182642
KVM: Convert the kvm->vcpus array to a xarray

At least on arm64 and x86, the vcpus array is pretty huge (up to
1024 entries on x86) and is mostly empty in the majority of the cases
(running 1k vcpu VMs is not that common).

This mean that we end-up with a 4kB block of unused memory in the
middle of the kvm structure.

Instead of wasting away this memory, let's use an xarray instead,
which gives us almost the same flexibility as a normal array, but
with a reduced memory usage with smaller VMs.

Signed-off-by: Marc Zyngier <maz@kernel.org>
Message-Id: <20211116160403.4074052-6-maz@kernel.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
include/linux/kvm_host.h
virt/kvm/kvm_main.c