linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC 0/3] Add NUMA mempolicy support for KVM guest_memfd
@ 2024-09-16 16:57 Shivank Garg
  2024-09-16 16:57 ` [PATCH RFC 1/3] KVM: guest_memfd: Extend creation API to support NUMA mempolicy Shivank Garg
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Shivank Garg @ 2024-09-16 16:57 UTC (permalink / raw)
  To: pbonzini, corbet, akpm, willy
  Cc: acme, namhyung, mpe, isaku.yamahata, joel, kvm, linux-doc,
	linux-kernel, linux-mm, linux-fsdevel, shivankg, shivansh.dhiman,
	bharata, nikunj

The current implementation of KVM guest-memfd does not honor the settings
provided by VMM. While mbind() can be used for NUMA policy support in
userspace applications, it is not functional for guest-memfd as the memory
is not mapped to userspace.

This patch-series adds support to specify NUMA memory policy for guests
with private guest-memfd memory backend. KVM guest-memfd support for
memory backend is already available in QEMU RAMBlock. However, the NUMA
support was missing. This cause memory allocation from guest to randomly
allocate on host NUMA nodes even when passing policy and host-nodes in the
QEMU command. It ensures that VMM provided NUMA policy is adhered.

This feature is particularly useful for SEV-SNP guests as they require
guest_memfd memory backend for allocations. Workloads with high memory-
locality are likely to benefit with this change.

Users can provide a policy mode such as default, bind, interleave, or
preferred along with a list of node IDs from the host machine.

To try this patch-series, build the custom QEMU with NUMA supported KVM
guest-memfd:
QEMU tree- https://github.com/AMDESE/qemu/tree/NUMA_guest_memfd
For instance, to run a SEV-SNP guest bound to NUMA Node 0 of the host,
the corresponding QEMU command would be:

$ qemu-system-x86_64 \
   -enable-kvm \
  ...
   -machine memory-encryption=sev0,vmport=off \
   -object sev-snp-guest,id=sev0,cbitpos=51,reduced-phys-bits=1 \
   -numa node,nodeid=0,memdev=ram0,cpus=0-15 \
   -object memory-backend-memfd,id=ram0,policy=bind,host-nodes=0,size=1024M,share=true,prealloc=false


Shivansh Dhiman (3):
  KVM: guest_memfd: Extend creation API to support NUMA mempolicy
  mm: add mempolicy support to the filemap layer
  KVM: guest_memfd: Enforce NUMA mempolicy if available

 Documentation/virt/kvm/api.rst | 13 ++++++++-
 include/linux/mempolicy.h      |  4 +++
 include/linux/pagemap.h        | 30 +++++++++++++++++++
 include/uapi/linux/kvm.h       |  5 +++-
 mm/filemap.c                   | 30 +++++++++++++++----
 mm/mempolicy.c                 | 53 ++++++++++++++++++++++++++++++++++
 tools/include/uapi/linux/kvm.h |  5 +++-
 virt/kvm/guest_memfd.c         | 28 ++++++++++++++----
 virt/kvm/kvm_mm.h              |  3 ++
 9 files changed, 158 insertions(+), 13 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-09-17 12:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-16 16:57 [PATCH RFC 0/3] Add NUMA mempolicy support for KVM guest_memfd Shivank Garg
2024-09-16 16:57 ` [PATCH RFC 1/3] KVM: guest_memfd: Extend creation API to support NUMA mempolicy Shivank Garg
2024-09-16 16:57 ` [PATCH RFC 2/3] mm: Add mempolicy support to the filemap layer Shivank Garg
2024-09-16 21:42   ` Matthew Wilcox
2024-09-17 12:43     ` Shivank Garg
2024-09-16 16:57 ` [PATCH RFC 3/3] KVM: guest_memfd: Enforce NUMA mempolicy if available Shivank Garg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).