From: kaleshsingh@google.com
To: akpm@linux-foundation.org
Cc: kernel-team@android.com, android-mm@google.com,
Kalesh Singh <kaleshsingh@google.com>,
Lokesh Gidra <lokeshgidra@google.com>,
Mike Rapoport <rppt@kernel.org>, Peter Xu <peterx@redhat.com>,
David Hildenbrand <david@kernel.org>,
Lorenzo Stoakes <ljs@kernel.org>,
"Liam R. Howlett" <liam@infradead.org>,
Vlastimil Babka <vbabka@kernel.org>,
Suren Baghdasaryan <surenb@google.com>,
Michal Hocko <mhocko@suse.com>, Shuah Khan <shuah@kernel.org>,
Ryan Roberts <ryan.roberts@arm.com>,
linux-mm@kvack.org, linux-kselftest@vger.kernel.org
Subject: [PATCH 1/2] selftests/mm: uffd-wp-mremap: skip unsupported shmem and hugetlb cases
Date: Sun, 22 Nov 2026 08:20:17 +0000 [thread overview]
Message-ID: <20261122082020.1255434-2-kaleshsingh@google.com> (raw)
In-Reply-To: <20261122082020.1255434-1-kaleshsingh@google.com>
From: Kalesh Singh <kaleshsingh@google.com>
uffd-wp-mremap checks only for UFFD_FEATURE_PAGEFAULT_FLAG_WP before it
runs. With CONFIG_PTE_MARKER_UFFD_WP=n the kernel keeps that feature
but supports write protection on anonymous memory only, so the shmem
and hugetlb cases fail with EINVAL from UFFDIO_REGISTER instead of
skipping. Skip them when UFFD_FEATURE_WP_HUGETLBFS_SHMEM is missing.
Fixes: b2466bb3b495 ("selftests/mm: introduce uffd-wp-mremap regression test")
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Lokesh Gidra <lokeshgidra@google.com>
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
---
tools/testing/selftests/mm/uffd-wp-mremap.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/tools/testing/selftests/mm/uffd-wp-mremap.c b/tools/testing/selftests/mm/uffd-wp-mremap.c
index c48eaab8e75c..f7b272baa6f5 100644
--- a/tools/testing/selftests/mm/uffd-wp-mremap.c
+++ b/tools/testing/selftests/mm/uffd-wp-mremap.c
@@ -18,15 +18,14 @@ static int nr_thpsizes;
static size_t thpsizes[20];
static int nr_hugetlbsizes;
static unsigned long hugetlbsizes[10];
+static uint64_t uffd_features;
static void check_uffd_wp_feature_supported(void)
{
- uint64_t features = 0;
-
- if (uffd_get_features(&features))
+ if (uffd_get_features(&uffd_features))
ksft_exit_skip("failed to get available features (%d)\n", errno);
- if (!(features & UFFD_FEATURE_PAGEFAULT_FLAG_WP))
+ if (!(uffd_features & UFFD_FEATURE_PAGEFAULT_FLAG_WP))
ksft_exit_skip("uffd-wp feature not supported\n");
}
@@ -180,6 +179,12 @@ static void test_one_folio(uffd_global_test_opts_t *gopts, size_t size, bool pri
swapout ? "true" : "false",
hugetlb ? "true" : "false");
+ if ((!private || hugetlb) &&
+ !(uffd_features & UFFD_FEATURE_WP_HUGETLBFS_SHMEM)) {
+ ksft_test_result_skip("uffd-wp on shmem and hugetlbfs is not supported\n");
+ return;
+ }
+
/* Allocate a folio of required size and type. */
mem = alloc_one_folio(size, private, hugetlb);
if (!mem) {
--
2.56.1.750.gf70dc682cf-goog
next prev parent reply other threads:[~2026-11-22 8:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-22 8:20 [PATCH 0/2] selftests/mm: fix userfaultfd tests with CONFIG_PTE_MARKER_UFFD_WP=n kaleshsingh
2026-11-22 8:20 ` kaleshsingh [this message]
2026-11-24 14:13 ` [PATCH 1/2] selftests/mm: uffd-wp-mremap: skip unsupported shmem and hugetlb cases Liam R. Howlett
2026-11-22 8:20 ` [PATCH 2/2] selftests/mm: uffd-unit-tests: filter required features per memory type kaleshsingh
2026-11-24 14:14 ` Liam R. Howlett
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=20261122082020.1255434-2-kaleshsingh@google.com \
--to=kaleshsingh@google.com \
--cc=akpm@linux-foundation.org \
--cc=android-mm@google.com \
--cc=david@kernel.org \
--cc=kernel-team@android.com \
--cc=liam@infradead.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=lokeshgidra@google.com \
--cc=mhocko@suse.com \
--cc=peterx@redhat.com \
--cc=rppt@kernel.org \
--cc=ryan.roberts@arm.com \
--cc=shuah@kernel.org \
--cc=surenb@google.com \
--cc=vbabka@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