Skip to content

Commit 735b3f7

Browse files
Ryan Robertsakpm00
authored andcommitted
selftests/mm: uffd-unit-tests support for hugepages > 2M
uffd-unit-tests uses a memory area with a fixed 32M size. Then it calculates the number of pages by dividing by page_size, which itself is either the base page size or the PMD huge page size depending on the test config. For the latter, we end up with nr_pages=1 for arm64 16K base pages, and nr_pages=0 for 64K base pages. This doesn't end well. So let's make the 32M size a floor and also ensure that we have at least 2 pages given the PMD size. With this change, the tests pass on arm64 64K base page size configuration. Link: https://lkml.kernel.org/r/20250318174343.243631-2-ryan.roberts@arm.com Signed-off-by: Ryan Roberts <ryan.roberts@arm.com> Acked-by: Peter Xu <peterx@redhat.com> Acked-by: Rafael Aquini <raquini@redhat.com> Cc: Shuah Khan <shuah@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent af96c61 commit 735b3f7

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

tools/testing/selftests/mm/uffd-unit-tests.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
#define ALIGN_UP(x, align_to) \
2727
((__typeof__(x))((((unsigned long)(x)) + ((align_to)-1)) & ~((align_to)-1)))
2828

29+
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
30+
2931
struct mem_type {
3032
const char *name;
3133
unsigned int mem_flag;
@@ -196,7 +198,8 @@ uffd_setup_environment(uffd_test_args_t *args, uffd_test_case_t *test,
196198
else
197199
page_size = psize();
198200

199-
nr_pages = UFFD_TEST_MEM_SIZE / page_size;
201+
/* Ensure we have at least 2 pages */
202+
nr_pages = MAX(UFFD_TEST_MEM_SIZE, page_size * 2) / page_size;
200203
/* TODO: remove this global var.. it's so ugly */
201204
nr_parallel = 1;
202205

0 commit comments

Comments
 (0)