From: Shivank Garg <shivankg@amd.com>
To: <x86@kernel.org>, <viro@zeniv.linux.org.uk>, <brauner@kernel.org>,
<jack@suse.cz>, <akpm@linux-foundation.org>,
<linux-kernel@vger.kernel.org>, <linux-fsdevel@vger.kernel.org>,
<linux-mm@kvack.org>, <linux-api@vger.kernel.org>,
<linux-arch@vger.kernel.org>, <kvm@vger.kernel.org>
Cc: <chao.gao@intel.com>, <pgonda@google.com>,
<thomas.lendacky@amd.com>, <seanjc@google.com>, <luto@kernel.org>,
<tglx@linutronix.de>, <mingo@redhat.com>, <bp@alien8.de>,
<dave.hansen@linux.intel.com>, <willy@infradead.org>,
<arnd@arndb.de>, <pbonzini@redhat.com>, <kees@kernel.org>,
<shivankg@amd.com>, <bharata@amd.com>, <nikunj@amd.com>,
<michael.day@amd.com>, <Neeraj.Upadhyay@amd.com>
Subject: [RFC PATCH 0/4] Add fbind() and NUMA mempolicy support for KVM guest_memfd
Date: Tue, 5 Nov 2024 16:45:45 +0000 [thread overview]
Message-ID: <20241105164549.154700-1-shivankg@amd.com> (raw)
This patch series introduces fbind() syscall to support NUMA memory
policies for KVM guest_memfd, allowing VMMs to configure memory placement
for guest memory. This addresses the current limitation where guest_memfd
allocations ignore NUMA policies, potentially impacting performance of
memory-locality-sensitive workloads.
Currently, while mbind() enables NUMA policy support for userspace
applications, it cannot be used with guest_memfd as the memory isn't mapped
to userspace. This results in guest memory being allocated randomly across
host NUMA nodes, even when specific policies and node preferences are
specified in QEMU commands.
The fbind() syscall is particularly useful for SEV-SNP guests.
Following suggestions from LPC and review comment [1], I switched from an
IOCTL-based approach [2] to fbind() [3]. The fbind() approach is preferred
as it provides a generic NUMA policy configuration working with any fd,
rather than being tied to guest-memfd.
Testing:
QEMU tree- https://github.com/AMDESE/qemu/tree/guest_memfd_fbind_NUMA
Based upon
Github tree- https://github.com/AMDESE/linux/tree/snp-host-latest
Branch: snp-host-latest commit: 85ef1ac
Example command to run a SEV-SNP guest bound to NUMA Node 0 of the host:
$ 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
[1]: https://lore.kernel.org/linux-mm/ZvEga7srKhympQBt@intel.com/
[2]: https://lore.kernel.org/linux-mm/20240919094438.10987-1-shivankg@amd.com
[3]: https://lore.kernel.org/kvm/ZOjpIL0SFH+E3Dj4@google.com/
Shivank Garg (3):
Introduce fbind syscall
KVM: guest_memfd: Pass file pointer instead of inode in guest_memfd
APIs
KVM: guest_memfd: Enforce NUMA mempolicy if available
Shivansh Dhiman (1):
mm: Add mempolicy support to the filemap layer
arch/x86/entry/syscalls/syscall_32.tbl | 1 +
arch/x86/entry/syscalls/syscall_64.tbl | 1 +
include/linux/fs.h | 3 ++
include/linux/mempolicy.h | 3 ++
include/linux/pagemap.h | 40 ++++++++++++++++
include/linux/syscalls.h | 3 ++
include/uapi/asm-generic/unistd.h | 5 +-
kernel/sys_ni.c | 1 +
mm/Makefile | 2 +-
mm/fbind.c | 49 +++++++++++++++++++
mm/filemap.c | 30 ++++++++++--
mm/mempolicy.c | 57 ++++++++++++++++++++++
virt/kvm/guest_memfd.c | 66 +++++++++++++++++++++-----
13 files changed, 242 insertions(+), 19 deletions(-)
create mode 100644 mm/fbind.c
--
2.34.1
next reply other threads:[~2024-11-05 16:47 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-05 16:45 Shivank Garg [this message]
2024-11-05 16:45 ` [RFC PATCH 1/4] mm: Add mempolicy support to the filemap layer Shivank Garg
2024-11-05 16:55 ` [RFC PATCH 2/4] Introduce fbind syscall Shivank Garg
2024-11-05 16:55 ` [RFC PATCH 3/4] KVM: guest_memfd: Pass file pointer instead of inode in guest_memfd APIs Shivank Garg
2024-11-05 16:55 ` [RFC PATCH 4/4] KVM: guest_memfd: Enforce NUMA mempolicy if available Shivank Garg
2024-11-05 18:55 ` [RFC PATCH 0/4] Add fbind() and NUMA mempolicy support for KVM guest_memfd Matthew Wilcox
2024-11-07 8:54 ` Shivank Garg
2024-11-07 15:10 ` Matthew Wilcox
2024-11-08 9:21 ` Shivank Garg
2024-11-08 17:31 ` Paolo Bonzini
2024-11-11 11:02 ` Vlastimil Babka
2024-11-11 22:14 ` David Hildenbrand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241105164549.154700-1-shivankg@amd.com \
--to=shivankg@amd.com \
--cc=Neeraj.Upadhyay@amd.com \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=bharata@amd.com \
--cc=bp@alien8.de \
--cc=brauner@kernel.org \
--cc=chao.gao@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=jack@suse.cz \
--cc=kees@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=linux-api@vger.kernel.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=luto@kernel.org \
--cc=michael.day@amd.com \
--cc=mingo@redhat.com \
--cc=nikunj@amd.com \
--cc=pbonzini@redhat.com \
--cc=pgonda@google.com \
--cc=seanjc@google.com \
--cc=tglx@linutronix.de \
--cc=thomas.lendacky@amd.com \
--cc=viro@zeniv.linux.org.uk \
--cc=willy@infradead.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox