diff options
author | Marc Orr <marcorr@google.com> | 2018-05-15 04:37:37 -0700 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2018-06-01 19:18:26 +0200 |
commit | d1e5b0e98ea27b4f17871dc4e8ea4b0447e35221 (patch) | |
tree | b0e6a402dc55ae6809456f40b690360cc8b687ca /virt | |
parent | 1499fa809e9e6713952ef84a7e9d51606881681f (diff) | |
download | op-kernel-dev-d1e5b0e98ea27b4f17871dc4e8ea4b0447e35221.zip op-kernel-dev-d1e5b0e98ea27b4f17871dc4e8ea4b0447e35221.tar.gz |
kvm: Make VM ioctl do valloc for some archs
The kvm struct has been bloating. For example, it's tens of kilo-bytes
for x86, which turns out to be a large amount of memory to allocate
contiguously via kzalloc. Thus, this patch does the following:
1. Uses architecture-specific routines to allocate the kvm struct via
vzalloc for x86.
2. Switches arm to __KVM_HAVE_ARCH_VM_ALLOC so that it can use vzalloc
when has_vhe() is true.
Other architectures continue to default to kalloc, as they have a
dependency on kalloc or have a small-enough struct kvm.
Signed-off-by: Marc Orr <marcorr@google.com>
Reviewed-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'virt')
-rw-r--r-- | virt/kvm/arm/arm.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/virt/kvm/arm/arm.c b/virt/kvm/arm/arm.c index 3d92214..72be779 100644 --- a/virt/kvm/arm/arm.c +++ b/virt/kvm/arm/arm.c @@ -251,6 +251,21 @@ long kvm_arch_dev_ioctl(struct file *filp, return -EINVAL; } +struct kvm *kvm_arch_alloc_vm(void) +{ + if (!has_vhe()) + return kzalloc(sizeof(struct kvm), GFP_KERNEL); + + return vzalloc(sizeof(struct kvm)); +} + +void kvm_arch_free_vm(struct kvm *kvm) +{ + if (!has_vhe()) + kfree(kvm); + else + vfree(kvm); +} struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, unsigned int id) { |