Re: [kvm PATCH v4 1/1] kvm: Make VM ioctl do valloc for some archs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Got it. I'll send another version shortly.
Thanks,
Marc
On Tue, May 15, 2018 at 1:44 AM Marc Zyngier <marc.zyngier@xxxxxxx> wrote:

> On 14/05/18 20:01, Marc Orr wrote:
> > 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 allocat the kvm struct via
> >    kzalloc for x86 and also for arm when has_tbe() is true.
> > 2. Introduces a baseline allocator for the kvm struct that uses valloc.
> >    This allocator can be used by an architecture by defining the
> >    __KVM_VALLOC_ARCH_VM macro before including include/linux/kvm_host.h.
> > 3. Finally, continue to default to kalloc for all other situations, as
> >    many architectures have taken a dependence on kalloc.
> >
> > Signed-off-by: Marc Orr <marcorr@xxxxxxxxxx>
> > Change-Id: Ide392e51991142d1325e06351231ac685e11d820
> > ---
> >  arch/arm/include/asm/kvm_host.h   |  4 ++++
> >  arch/arm/kvm/guest.c              | 16 ++++++++++++++++
> >  arch/arm64/include/asm/kvm_host.h |  4 ++++
> >  arch/arm64/kvm/guest.c            | 16 ++++++++++++++++
> >  arch/x86/kvm/svm.c                |  4 ++--
> >  arch/x86/kvm/vmx.c                |  4 ++--
> >  include/linux/kvm_host.h          | 13 +++++++++++++
> >  7 files changed, 57 insertions(+), 4 deletions(-)
> >
> > diff --git a/arch/arm/include/asm/kvm_host.h
b/arch/arm/include/asm/kvm_host.h
> > index c7c28c885a19..f38fd60b4d4d 100644
> > --- a/arch/arm/include/asm/kvm_host.h
> > +++ b/arch/arm/include/asm/kvm_host.h
> > @@ -318,4 +318,8 @@ static inline bool
kvm_arm_harden_branch_predictor(void)
> >  static inline void kvm_vcpu_load_sysregs(struct kvm_vcpu *vcpu) {}
> >  static inline void kvm_vcpu_put_sysregs(struct kvm_vcpu *vcpu) {}
> >
> > +#define __KVM_HAVE_ARCH_VM_ALLOC
> > +struct kvm *kvm_arch_alloc_vm(void);
> > +void kvm_arch_free_vm(struct kvm *kvm);
> > +
> >  #endif /* __ARM_KVM_HOST_H__ */
> > diff --git a/arch/arm/kvm/guest.c b/arch/arm/kvm/guest.c
> > index a18f33edc471..2b88b745f5a3 100644
> > --- a/arch/arm/kvm/guest.c
> > +++ b/arch/arm/kvm/guest.c
> > @@ -42,6 +42,22 @@ struct kvm_stats_debugfs_item debugfs_entries[] = {
> >       { NULL }
> >  };
> >
> > +struct kvm *kvm_arch_alloc_vm(void)
> > +{
> > +     if (!has_vhe())
> > +             return kzalloc(sizeof(struct kvm), GFP_KERNEL);
> > +
> > +     return vzalloc(sizeof(struct kvm));

> This doesn't make much sense.

> Either you pick the patch I provided which makes the allocation a common
> path between arm and arm64 by sticking it in common code (and then the
> has_vhe()) test makes sense), or you make it per-architecture, and the
> whole has_vhe() for 32bit ARM is just churn (to the point where you
> shouldn't define __KVM_HAVE_ARCH_VM_ALLOC at all for that architecture).

> Thanks,

>          M.
> --
> Jazz is not dead. It just smells funny...



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux