From: Shivank Garg <shivankg@amd.com>
To: Sean Christopherson <seanjc@google.com>,
Paolo Bonzini <pbonzini@redhat.com>,
David Hildenbrand <david@kernel.org>,
Shuah Khan <shuah@kernel.org>, Jim Mattson <jmattson@google.com>,
Peter Shier <pshier@google.com>,
Ricardo Koller <ricarkol@google.com>,
Ackerley Tng <ackerleytng@google.com>
Cc: <kvm@vger.kernel.org>, <linux-kselftest@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, Shivank Garg <shivankg@amd.com>
Subject: [PATCH v3 2/4] KVM: selftests: Use an allowed memory node in test_mbind()
Date: Mon, 7 Sep 2026 07:24:58 +0000 [thread overview]
Message-ID: <20260907-gmem-selftests-fix-v3-2-7a4be5c1cc8a@amd.com> (raw)
In-Reply-To: <20260907-gmem-selftests-fix-v3-0-7a4be5c1cc8a@amd.com>
test_mbind() hardcodes node 0 and skips the test unless sysfs reports
more than one NUMA node. This can fail if node 0 has no memory or is
excluded by the task's cpuset.
Pick a node from MPOL_F_MEMS_ALLOWED instead. The test only needs one
node, so allow it to run on single-node systems too.
Signed-off-by: Shivank Garg <shivankg@amd.com>
---
tools/testing/selftests/kvm/guest_memfd_test.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/kvm/guest_memfd_test.c b/tools/testing/selftests/kvm/guest_memfd_test.c
index b3bd03167ba8..ea8e38064e83 100644
--- a/tools/testing/selftests/kvm/guest_memfd_test.c
+++ b/tools/testing/selftests/kvm/guest_memfd_test.c
@@ -81,15 +81,16 @@ static void test_mbind(int fd, size_t total_size)
unsigned long nodemask = 0;
unsigned long maxnode = MAXNODE_FOR_MASK(nodemask);
unsigned long bind_nodemask;
+ unsigned long mems_allowed;
int policy;
char *mem;
int nid;
int ret;
- if (!is_multi_numa_node_system())
+ if (!kvm_get_numa_memory_nodes(&mems_allowed))
return;
- nid = 0;
+ nid = kvm_get_next_numa_node(mems_allowed, -1);
bind_nodemask = BIT(nid);
mem = kvm_mmap(total_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd);
--
2.43.0
next prev parent reply other threads:[~2026-09-07 7:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-07 7:24 [PATCH v3 0/4] KVM: guest_memfd: fix NUMA selftests Shivank Garg
2026-09-07 7:24 ` [PATCH v3 1/4] KVM: selftests: Prepare guest_memfd_test for arbitrary NUMA nodes Shivank Garg
2026-09-07 7:24 ` Shivank Garg [this message]
2026-09-07 7:24 ` [PATCH v3 3/4] KVM: selftests: Use allowed memory nodes in test_numa_allocation() Shivank Garg
2026-09-07 7:25 ` [PATCH v3 4/4] KVM: selftests: Drop unused sysfs NUMA helpers Shivank Garg
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=20260907-gmem-selftests-fix-v3-2-7a4be5c1cc8a@amd.com \
--to=shivankg@amd.com \
--cc=ackerleytng@google.com \
--cc=david@kernel.org \
--cc=jmattson@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=pshier@google.com \
--cc=ricarkol@google.com \
--cc=seanjc@google.com \
--cc=shuah@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
all inboxes | Powered by JetHome®