Skip to content

RFC kvm: Growable memory slot array

Alex Williamson kvm lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest6 patches 21 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6kvm: Rename KVM_MEMORY_SLOTS -> KVM_USER_MEM_SLOTSarch/ia64/include/asm/kvm_host.h arch/ia64/kvm/kvm-ia64.c arch/powerpc/include/asm/kvm_host.h +7 more+19 -190 replies
2/6kvm: Make KVM_PRIVATE_MEM_SLOTS optionalarch/ia64/include/asm/kvm_host.h arch/powerpc/include/asm/kvm_host.h arch/s390/include/asm/kvm_host.h +2 more+7 -90 replies
3/6kvm: Merge id_to_index into memslotsinclude/linux/kvm_host.h virt/kvm/kvm_main.c+4 -52 replies
4/6kvm: Move private memory slots to start of memslots arrayarch/ia64/kvm/kvm-ia64.c arch/powerpc/kvm/book3s_hv.c arch/x86/include/asm/vmx.h +3 more+18 -132 replies
5/6kvm: Re-introduce memslots->nmemslotsarch/ia64/kvm/kvm-ia64.c arch/powerpc/kvm/book3s_hv.c arch/x86/kvm/vmx.c +3 more+18 -107 replies
6/6kvm: Allow memory slots to growinclude/linux/kvm_host.h virt/kvm/kvm_main.c+43 -210 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC PATCH 0/6] kvm: Growable memory slot array

Memory slots are currently a fixed resource with a relatively small limit. When using PCI device assignment in a qemu guest it's fairly easy to exhaust the number of available slots. I posted patches exploring growing the number of memory slots a while ago, but it was prior to caching memory slot array misses and thefore had potentially poor performance. Now that we do that, Avi seemed receptive to increasing the memory slot array to arbitrary lengths. I think we still don't want to impose unnecessary kernel memory consumptions on guests not making use of this, so I present again a growable memory slot array.

A couple notes/questions; in the previous version we had a kvm_arch_flush_shadow() call when we increased the number of slots. I'm not sure if this is still necessary. I had also made the x86 specific slot_bitmap dynamically grow as well and switch between a direct bitmap and indirect pointer to a bitmap. That may have contributed to needing the flush. I haven't done that yet here because it seems like an unnecessary complication if we have a max on the order of 512 or 1024 entries. A bit per slot isn't a lot of overhead. If we want to go more, maybe we should make it switch. That leads to the final question, we need an upper bound since this does allow consumption of extra kernel memory, what should it be? A PCI bus filled with assigned devices can theorically use up to 2048 slots (32 devices * 8 functions * (6 BARs + ROM + possibly split MSI-X BAR)). For this RFC, I don't change the max, just make it grow up to 32 user slots. Untested on anything but x86 so far. Thanks,

Alex
---

Alex Williamson (6):
kvm: Rename KVM_MEMORY_SLOTS -> KVM_USER_MEM_SLOTS
kvm: Make KVM_PRIVATE_MEM_SLOTS optional
kvm: Merge id_to_index into memslots
kvm: Move private memory slots to start of memslots array
kvm: Re-introduce memslots->nmemslots
kvm: Allow memory slots to grow

 arch/ia64/include/asm/kvm_host.h    |    4 --
 arch/ia64/kvm/kvm-ia64.c            |    6 +--
 arch/powerpc/include/asm/kvm_host.h |    6 +--
 arch/powerpc/kvm/book3s_hv.c        |    4 +-
 arch/s390/include/asm/kvm_host.h    |    4 --
 arch/x86/include/asm/kvm_host.h     |    8 ++-
 arch/x86/include/asm/vmx.h          |    6 +--
 arch/x86/kvm/vmx.c                  |    3 +
 arch/x86/kvm/x86.c                  |   10 +++-
 include/linux/kvm_host.h            |   20 +++++---
 virt/kvm/kvm_main.c                 |   83 ++++++++++++++++++++++++-----------
 11 files changed, 93 insertions(+), 61 deletions(-)