From: "John J. Coleman" <jocolema@redhat.com>
To: linux-mm@kvack.org, linux-kernel@vger.kernel.org
Cc: zenghui.yu@linux.dev, akpm@linux-foundation.org,
david@kernel.org, liam@infradead.org, ljs@kernel.org,
mhocko@suse.com, peterx@redhat.com, rppt@kernel.org,
surenb@google.com, vbabka@kernel.org, audra@redhat.com
Subject: [PATCH] selftests/mm: allocate nr_pages based on pmd size for uffd pmd_move tests
Date: Thu, 12 Nov 2026 21:00:45 -0700 [thread overview]
Message-ID: <20261113040045.1439391-1-jocolema@redhat.com> (raw)
When executing the uffd-unit-test, the "move-pmd on anon" test will fail
on aarch64+64k with a segmentation fault because the initial allocated
memory region is too small. This only happens with the move-pmd* tests
because the architecture base page size is still utilized even though the
memory region is specific to the size indicated by the pmd.
Patch 9f5c2aec3388 ("selftests/mm: fix uffd move-pmd test crash on 64K
base page systems") implements an initial fix to the segmentation fault
by skipping the test if the allocated memory region is not large enough
for the number of pages x page size requested. Since this will skip over
the aarch64+64k pmd tests, this patch is intended to resolve the problem
with 64k pages by pre-allocating the memory region with 2x the pmd page
size (for area_src and area_dst) for only the move_pmd tests by using the
uffd_test_case_ops pre_alloc hook.
Link: https://lore.kernel.org/all/20261103202049.499206-1-jocolema@redhat.com
Fixes: a2bf6a9ca805 ("selftests/mm: add UFFDIO_MOVE ioctl test")
Signed-off-by: John J. Coleman <jocolema@redhat.com>
---
I initially included patches V1 and V2 through the linked email thread.
V1 and V2 modified UFFD_TEST_MEM_SIZE contingent upon base page size and
a multiplier. However, sashiko review observed alignment issues with
powerpc64 with 2MiB and 16MiB pmd sizes as well as 32bit type overflows.
Subseqent to sashiko review I decided to make a significant change hence
why I created a new patch rather than continuing with V3. This patch
leaves UFFD_TEST_MEM_SIZE at the 32MiB arbitrary value and utilizes the
pre_alloc callback within the uffd_test_case_ops object to set nr_pages
based on 2x retrieved PMD size divided by the base page size for both
source and destination test allocated memory regions.
tools/testing/selftests/mm/uffd-unit-tests.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/tools/testing/selftests/mm/uffd-unit-tests.c b/tools/testing/selftests/mm/uffd-unit-tests.c
index 2a97ba1d6feb1b35d6281449fd1917793a64fab1..0846de62689f710bab320e399d0bb5849b9408ff 100644
--- a/tools/testing/selftests/mm/uffd-unit-tests.c
+++ b/tools/testing/selftests/mm/uffd-unit-tests.c
@@ -2226,6 +2226,20 @@ static void uffd_mmap_changing_test(uffd_global_test_opts_t *gopts, uffd_test_ar
uffd_test_pass();
}
+static int set_pmd_pagesize_nr_pages(uffd_global_test_opts_t *gopts, const char **errmsg)
+{
+ uint64_t pmd_pagesize = read_pmd_pagesize();
+ if (!pmd_pagesize) {
+ if(errmsg)
+ *errmsg = "failed to retrieve pmd page size";
+ return -1;
+ }
+
+ gopts->nr_pages = (2 * pmd_pagesize) / gopts->page_size;
+
+ return 0;
+}
+
static int prevent_hugepages(uffd_global_test_opts_t *gopts, const char **errmsg)
{
/* This should be done before source area is populated */
@@ -2259,6 +2273,7 @@ struct uffd_test_case_ops uffd_move_test_case_ops = {
};
struct uffd_test_case_ops uffd_move_test_pmd_case_ops = {
+ .pre_alloc = set_pmd_pagesize_nr_pages,
.post_alloc = request_hugepages,
};
--
2.56.0
reply other threads:[~2026-11-13 4:01 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261113040045.1439391-1-jocolema@redhat.com \
--to=jocolema@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=audra@redhat.com \
--cc=david@kernel.org \
--cc=liam@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mhocko@suse.com \
--cc=peterx@redhat.com \
--cc=rppt@kernel.org \
--cc=surenb@google.com \
--cc=vbabka@kernel.org \
--cc=zenghui.yu@linux.dev \
/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®