linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Ryan Roberts <ryan.roberts@arm.com>
To: Andrew Morton <akpm@linux-foundation.org>,
	Shuah Khan <shuah@kernel.org>, Peter Xu <peterx@redhat.com>
Cc: Ryan Roberts <ryan.roberts@arm.com>,
	linux-mm@kvack.org, linux-kselftest@vger.kernel.org
Subject: [PATCH v1 2/3] selftests/mm: uffd-unit-tests support for hugepages > 2M
Date: Tue, 18 Mar 2025 17:43:40 +0000	[thread overview]
Message-ID: <20250318174343.243631-2-ryan.roberts@arm.com> (raw)
In-Reply-To: <20250318174343.243631-1-ryan.roberts@arm.com>

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.

Signed-off-by: Ryan Roberts <ryan.roberts@arm.com>
---
 tools/testing/selftests/mm/uffd-unit-tests.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/mm/uffd-unit-tests.c b/tools/testing/selftests/mm/uffd-unit-tests.c
index 74c8bc02b506..6973e57b227a 100644
--- a/tools/testing/selftests/mm/uffd-unit-tests.c
+++ b/tools/testing/selftests/mm/uffd-unit-tests.c
@@ -26,6 +26,8 @@
 #define ALIGN_UP(x, align_to) \
 	((__typeof__(x))((((unsigned long)(x)) + ((align_to)-1)) & ~((align_to)-1)))
 
+#define MAX(a, b) (((a) > (b)) ? (a) : (b))
+
 struct mem_type {
 	const char *name;
 	unsigned int mem_flag;
@@ -196,7 +198,8 @@ uffd_setup_environment(uffd_test_args_t *args, uffd_test_case_t *test,
 	else
 		page_size = psize();
 
-	nr_pages = UFFD_TEST_MEM_SIZE / page_size;
+	/* Ensure we have at least 2 pages */
+	nr_pages = MAX(UFFD_TEST_MEM_SIZE, page_size * 2) / page_size;
 	/* TODO: remove this global var.. it's so ugly */
 	nr_cpus = 1;
 
-- 
2.43.0



  reply	other threads:[~2025-03-18 17:43 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-18 17:43 [PATCH v1 1/3] selftests/mm: Fix half_ufd_size_MB calculation Ryan Roberts
2025-03-18 17:43 ` Ryan Roberts [this message]
2025-03-18 19:54   ` [PATCH v1 2/3] selftests/mm: uffd-unit-tests support for hugepages > 2M Peter Xu
2025-03-18 21:52   ` Rafael Aquini
2025-03-18 17:43 ` [PATCH v1 3/3] selftests/mm: Speed up split_huge_page_test Ryan Roberts
2025-03-18 19:54   ` Peter Xu
2025-03-18 21:53   ` Rafael Aquini
2025-03-18 19:54 ` [PATCH v1 1/3] selftests/mm: Fix half_ufd_size_MB calculation Peter Xu
2025-03-18 22:05   ` Ryan Roberts
2025-03-18 21:49 ` Rafael Aquini

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=20250318174343.243631-2-ryan.roberts@arm.com \
    --to=ryan.roberts@arm.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=peterx@redhat.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