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 3/4] KVM: selftests: Use allowed memory nodes in test_numa_allocation()
Date: Mon, 7 Sep 2026 07:24:59 +0000 [thread overview]
Message-ID: <20260907-gmem-selftests-fix-v3-3-7a4be5c1cc8a@amd.com> (raw)
In-Reply-To: <20260907-gmem-selftests-fix-v3-0-7a4be5c1cc8a@amd.com>
test_numa_allocation() assumes that nodes 0 and 1 exist and are usable.
That is not guaranteed on systems with sparse or memoryless nodes, or
when a cpuset restricts the task.
Pick two nodes from MPOL_F_MEMS_ALLOWED and use MAXNODE_FOR_MASK() when
passing the masks to mbind(). Keep the two-node requirement because the
test verifies that pages are allocated on different nodes.
Signed-off-by: Shivank Garg <shivankg@amd.com>
---
tools/testing/selftests/kvm/guest_memfd_test.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/tools/testing/selftests/kvm/guest_memfd_test.c b/tools/testing/selftests/kvm/guest_memfd_test.c
index ea8e38064e83..cc5abca1adae 100644
--- a/tools/testing/selftests/kvm/guest_memfd_test.c
+++ b/tools/testing/selftests/kvm/guest_memfd_test.c
@@ -127,18 +127,19 @@ static void test_mbind(int fd, size_t total_size)
static void test_numa_allocation(int fd, size_t total_size)
{
unsigned long node0_mask, node1_mask;
- unsigned long maxnode = 8;
+ unsigned long maxnode = MAXNODE_FOR_MASK(node0_mask);
+ unsigned long mems_allowed;
int nid0, nid1;
void *pages[4];
int status[4];
char *mem;
int i;
- if (!is_multi_numa_node_system())
+ if (kvm_get_numa_memory_nodes(&mems_allowed) < 2)
return;
- nid0 = 0;
- nid1 = 1;
+ nid0 = kvm_get_next_numa_node(mems_allowed, -1);
+ nid1 = kvm_get_next_numa_node(mems_allowed, nid0);
node0_mask = BIT(nid0);
node1_mask = BIT(nid1);
--
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 ` [PATCH v3 2/4] KVM: selftests: Use an allowed memory node in test_mbind() Shivank Garg
2026-09-07 7:24 ` Shivank Garg [this message]
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-3-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®