Skip to content

KVM: Make the maximum number of user memslots configurable and raise the default

Vitaly Kuznetsov kvm 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest5 patches 9 repliesIn review

Changes since RFC from the cover letter

- Re-wrote everything [Sean]. The maximum number of slots is now a per-VM thing controlled by an ioctl.

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5KVM: Make the maximum number of user memslots a per-VM thingarch/powerpc/kvm/book3s_hv.c arch/s390/kvm/kvm-s390.c include/linux/kvm_host.h +2 more+10 -89 replies
2/5KVM: Raise the maximum number of user memslotsarch/arm64/include/asm/kvm_host.h arch/mips/include/asm/kvm_host.h arch/powerpc/include/asm/kvm_host.h +4 more+3 -90 replies
3/5KVM: Make the maximum number of user memslots configurableDocumentation/virt/kvm/api.rst include/uapi/linux/kvm.h virt/kvm/kvm_main.c+47 -00 replies
4/5selftests: kvm: Test the newly introduced KVM_CAP_MEMSLOTS_LIMITtools/testing/selftests/kvm/include/kvm_util.h tools/testing/selftests/kvm/lib/kvm_util.c tools/testing/selftests/kvm/set_memory_region_test.c+67 -70 replies
5/5selftests: kvm: Raise the default timeout to 120 secondstools/testing/selftests/kvm/settings+1 -00 replies

Reviews trailers per patch

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

Read the v1 thread

Cover letter [PATCH 0/5] KVM: Make the maximum number of user memslots configurable and raise the default

This is a successor of previously sent "[PATCH RFC 0/4] KVM: x86:
Drastically raise KVM_USER_MEM_SLOTS limit".

Changes since RFC:
- Re-wrote everything [Sean]. The maximum number of slots is now a per-VM thing controlled by an ioctl.

Original description:

Current KVM_USER_MEM_SLOTS limit on x86 (509) can be a limiting factor for some configurations. In particular, when QEMU tries to start a Windows guest with Hyper-V SynIC enabled and e.g. 256 vCPUs the limit is hit as SynIC requires two pages per vCPU and the guest is free to pick any GFN for each of them, this fragments memslots as QEMU wants to have a separate memslot for each of these pages (which are supposed to act as 'overlay' pages).

Memory slots are allocated dynamically in KVM when added so the only real limitation is 'id_to_index' array which is 'short'. We don't seem to have any other KVM_MEM_SLOTS_NUM/KVM_USER_MEM_SLOTS-sized statically defined structures.

We could've just raised the limit to e.g. '1021' (we have 3 private memslots on x86) and this should be enough for now as KVM_MAX_VCPUS is '288' but AFAIK there are plans to raise this limit as well. Raise the default value to 32768 - KVM_PRIVATE_MEM_SLOTS and introduce a new ioctl to set the limit per-VM.

Vitaly Kuznetsov (5):
KVM: Make the maximum number of user memslots a per-VM thing
KVM: Raise the maximum number of user memslots
KVM: Make the maximum number of user memslots configurable
selftests: kvm: Test the newly introduced KVM_CAP_MEMSLOTS_LIMIT
selftests: kvm: Raise the default timeout to 120 seconds

 Documentation/virt/kvm/api.rst                | 16 +++++++
 arch/arm64/include/asm/kvm_host.h             |  1 -
 arch/mips/include/asm/kvm_host.h              |  1 -
 arch/powerpc/include/asm/kvm_host.h           |  1 -
 arch/powerpc/kvm/book3s_hv.c                  |  2 +-
 arch/s390/include/asm/kvm_host.h              |  1 -
 arch/s390/kvm/kvm-s390.c                      |  2 +-
 arch/x86/include/asm/kvm_host.h               |  2 -
 include/linux/kvm_host.h                      |  6 +--
 include/uapi/linux/kvm.h                      |  1 +
 .../testing/selftests/kvm/include/kvm_util.h  |  1 +
 tools/testing/selftests/kvm/lib/kvm_util.c    | 30 ++++++++++++-
 .../selftests/kvm/set_memory_region_test.c    | 43 ++++++++++++++++---
 tools/testing/selftests/kvm/settings          |  1 +
 virt/kvm/dirty_ring.c                         |  2 +-
 virt/kvm/kvm_main.c                           | 42 +++++++++++++++---
 16 files changed, 128 insertions(+), 24 deletions(-)
 create mode 100644 tools/testing/selftests/kvm/settings
Signature · 1 line
2.29.2