Skip to content

KVM: guest_memfd: Add NUMA mempolicy support

Sean Christopherson kvm kvmarm linux-arm-kernel lkml 2 versions – Applied

Status from this message: Applied to kvm-x86 gmem, sans the .clang-format change. Thanks!

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v13 Latest12 patches 18 repliesApplied
  2. v1212 patches 21 repliesSuperseded

Changes in v13 from the cover letter

- Collect reviews.
- Add kvm_gmem_for_each_file to .clang-format. [Ackerley]
- Fix typos. [Ackerley]
- Don't use get_task_policy() if the guest_memfd doesn't have its own policy, so that cpuset_do_page_mem_spread() works. [Ackerley]
- Fix goofs in the changelogs related to numaif.h. [Ackerley]

Patches in v13 Applied

#Subject and filesSizeRepliesApplied
1/12KVM: guest_memfd: Rename "struct kvm_gmem" to "struct gmem_file"virt/kvm/guest_memfd.c+53 -451 reply
2/12KVM: guest_memfd: Add macro to iterate over gmem_files for a mapping/inode.clang-format virt/kvm/guest_memfd.c+6 -41 reply
3/12KVM: guest_memfd: Use guest mem inodes instead of anonymous inodesinclude/uapi/linux/magic.h virt/kvm/guest_memfd.c virt/kvm/kvm_main.c +1 more+80 -190 replies
4/12KVM: guest_memfd: Add slab-allocated inode cachevirt/kvm/guest_memfd.c+76 -12 replies
5/12KVM: guest_memfd: Enforce NUMA mempolicy using shared policyvirt/kvm/guest_memfd.c+56 -20 replies
6/12KVM: selftests: Define wrappers for common syscalls to assert successtools/testing/selftests/kvm/arm64/vgic_irq.c tools/testing/selftests/kvm/include/kvm_syscalls.h tools/testing/selftests/kvm/include/kvm_util.h +3 more+96 -601 reply
7/12KVM: selftests: Report stacktraces SIGBUS, SIGSEGV, SIGILL, and SIGFPE by defaulttools/testing/selftests/kvm/lib/kvm_util.c+24 -01 reply
8/12KVM: selftests: Add additional equivalents to libnuma APIs in KVM's numaif.htools/testing/selftests/kvm/include/numaif.h tools/testing/selftests/kvm/x86/xapic_ipi_test.c+23 -181 reply
9/12KVM: selftests: Use proper uAPI headers to pick up mempolicy.h definitionstools/testing/selftests/kvm/include/numaif.h+1 -312 replies
10/12KVM: selftests: Add helpers to probe for NUMA support, and multi-node systemstools/testing/selftests/kvm/include/numaif.h+52 -00 replies
11/12KVM: selftests: Add guest_memfd tests for mmap and NUMA policy supporttools/testing/selftests/kvm/guest_memfd_test.c+98 -00 replies
12/12KVM: guest_memfd: Add gmem_inode.flags field instead of using i_privatevirt/kvm/guest_memfd.c+9 -61 reply

Reviews trailers per patch

10 of 12 patches have a Reviewed-by or Acked-by.

PatchAckerley TngShivank GargDavid HildenbrandAshish KalraVlastimil Babka
1/12R-b T-b R-b T-b
2/12R-b T-b R-b T-b
3/12A-b T-b
4/12R-b T-b T-b R-b
5/12A-b T-b A-b
6/12R-b T-b R-b T-b
7/12T-b R-b R-b T-b
8/12R-b T-b R-b T-b
9/12R-b T-b
10/12
11/12T-b
12/12R-b T-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 5 reviewers.

Read the v13 thread

Cover letter [PATCH v13 00/12] KVM: guest_memfd: Add NUMA mempolicy support

Miguel, you got pulled in due to a one-line change to add a new iterator macros in .clang-format.

Shivank's series to add support for NUMA-aware memory placement in guest_memfd. Based on kvm-x86/next.

Note, Ackerley pointed out that we should probably have testing for the cpuset_do_page_mem_spread() behavior. I 100% agree, but I'm also a-ok merging without those tests.

v13:
- Collect reviews.
- Add kvm_gmem_for_each_file to .clang-format. [Ackerley]
- Fix typos. [Ackerley]
- Don't use get_task_policy() if the guest_memfd doesn't have its own policy, so that cpuset_do_page_mem_spread() works. [Ackerley]
- Fix goofs in the changelogs related to numaif.h. [Ackerley]

v12:
- https://lore.kernel.org/all/[email protected]
- Add missing functionality to KVM selftests' existing numaif.h instead of linking to libnuma (which appears to have caveats with -static).
- Add KVM_SYSCALL_DEFINE() infrastructure to reduce the boilerplate needed to wrap syscalls and/or to assert that a syscall succeeds.
- Rename kvm_gmem to gmem_file, and use gmem_inode for the inode structure.
- Track flags in a gmem_inode field instead of using i_private.
- Add comments to call out subtleties in the mempolicy code (e.g. that returning NULL for vm_operations_struct.get_policy() is important for ABI reasons).
- Improve debugability of guest_memfd_test (I kept generating SIGBUS when tweaking the tests).
- Test mbind() with private memory (sadly, verifying placement with move_pages() doesn't work due to the dependency on valid page tables).

- V11: Rebase on kvm-next, remove RFC tag, use Ackerley's latest patch and fix a rcu race bug during kvm module unload.
- V10: Rebase on top of Fuad's V17. Use latest guest_memfd inode patch from Ackerley (with David's review comments). Use newer kmem_cache_create() API variant with arg parameter (Vlastimil)
- v9: Rebase on top of Fuad's V13 and incorporate review comments
- v8: Rebase on top of Fuad's V12: Host mmaping for guest_memfd memory.
- v7: Use inodes to store NUMA policy instead of file [0].
- v4-v6: Current approach using shared_policy support and vm_ops (based on suggestions from David [1] and guest_memfd bi-weekly upstream call discussion [2]).
- v3: Introduced fbind() syscall for VMM memory-placement configuration.
- v1,v2: Extended the KVM_CREATE_GUEST_MEMFD IOCTL to pass mempolicy.

[0] https://lore.kernel.org/all/[email protected]
[1] https://lore.kernel.org/all/[email protected]
[2] https://lore.kernel.org/all/[email protected]

Ackerley Tng (1):
KVM: guest_memfd: Use guest mem inodes instead of anonymous inodes

Sean Christopherson (7):
KVM: guest_memfd: Rename "struct kvm_gmem" to "struct gmem_file"
KVM: guest_memfd: Add macro to iterate over gmem_files for a
mapping/inode
KVM: selftests: Define wrappers for common syscalls to assert success
KVM: selftests: Report stacktraces SIGBUS, SIGSEGV, SIGILL, and SIGFPE
by default
KVM: selftests: Add additional equivalents to libnuma APIs in KVM's
numaif.h
KVM: selftests: Use proper uAPI headers to pick up mempolicy.h
definitions
KVM: guest_memfd: Add gmem_inode.flags field instead of using
i_private

Shivank Garg (4):
KVM: guest_memfd: Add slab-allocated inode cache
KVM: guest_memfd: Enforce NUMA mempolicy using shared policy
KVM: selftests: Add helpers to probe for NUMA support, and multi-node
systems
KVM: selftests: Add guest_memfd tests for mmap and NUMA policy support

 .clang-format                                 |   1 +
 include/uapi/linux/magic.h                    |   1 +
 tools/testing/selftests/kvm/arm64/vgic_irq.c  |   2 +-
 .../testing/selftests/kvm/guest_memfd_test.c  |  98 ++++++
 .../selftests/kvm/include/kvm_syscalls.h      |  81 +++++
 .../testing/selftests/kvm/include/kvm_util.h  |  29 +-
 tools/testing/selftests/kvm/include/numaif.h  | 110 +++---
 .../selftests/kvm/kvm_binary_stats_test.c     |   4 +-
 tools/testing/selftests/kvm/lib/kvm_util.c    |  55 +--
 .../kvm/x86/private_mem_conversions_test.c    |   9 +-
 .../selftests/kvm/x86/xapic_ipi_test.c        |   5 +-
 virt/kvm/guest_memfd.c                        | 331 ++++++++++++++----
 virt/kvm/kvm_main.c                           |   7 +-
 virt/kvm/kvm_mm.h                             |   9 +-
 14 files changed, 565 insertions(+), 177 deletions(-)
 create mode 100644 tools/testing/selftests/kvm/include/kvm_syscalls.h

base-commit: f222788458c8a7753d43befef2769cd282dc008e

Signature · 1 line
2.51.0.858.gf9c4a03a3a-goog