All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: mm-commits@vger.kernel.org,vbabka@kernel.org,surenb@google.com,
	shuah@kernel.org,ryan.roberts@arm.com,rppt@kernel.org,peterx@redhat.com,
	mhocko@suse.com,lokeshgidra@google.com,ljs@kernel.org,liam@infradead.org,
	david@kernel.org,kaleshsingh@google.com,akpm@linux-foundation.org
Subject: + selftests-mm-uffd-unit-tests-filter-required-features-per-memory-type.patch added to mm-new branch
Date: Tue, 24 Nov 2026 15:34:07 -0800	[thread overview]
Message-ID: <20261124233407.80CE51F000C6@smtp.kernel.org> (raw)
In-Reply-To: <20261122082020.1255434-3-kaleshsingh@google.com>


The patch titled
     Subject: selftests/mm: uffd-unit-tests: filter required features per memory type
has been added to the -mm mm-new branch.  Its filename is
     selftests-mm-uffd-unit-tests-filter-required-features-per-memory-type.patch

This patch will shortly appear at
     https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/selftests-mm-uffd-unit-tests-filter-required-features-per-memory-type.patch

This patch will later appear in the mm-new branch at
    git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

Note, mm-new is a provisional staging ground for work-in-progress
patches, and acceptance into mm-new is a notification for others take
notice and to finish up reviews.  Please do not hesitate to respond to
review feedback and post updated versions to replace or incrementally
fixup patches in mm-new.

The mm-new branch of mm.git is not included in linux-next

If a few days of testing in mm-new is successful, the patch will me moved
into mm.git's mm-unstable branch, which is included in linux-next

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next via various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days

------------------------------------------------------
From: Kalesh Singh <kaleshsingh@google.com>
Subject: selftests/mm: uffd-unit-tests: filter required features per memory type
Date: Sun, 22 Nov 2026 08:20:18 +0000

CONFIG_PTE_MARKER_UFFD_WP defaults to y but can be turned off, and
userfaultfd write protection then works only on anonymous memory.  The
kernel still reports UFFD_FEATURE_PAGEFAULT_FLAG_WP but no longer
UFFD_FEATURE_WP_HUGETLBFS_SHMEM.

uffd-unit-tests checks a test's whole feature mask for every memory type,
so the tests that run on all memory types and require
UFFD_FEATURE_WP_HUGETLBFS_SHMEM (register-ioctls, the wp-fork tests,
rwp-wp-exclusive, sigbus-wp and events-wp) skip their anonymous runs too. 
Check and request only the features that apply to the memory type under
test, and make minor-wp require UFFD_FEATURE_WP_HUGETLBFS_SHMEM, as it
write-protects shmem and hugetlbfs.

Link: https://patch.msgid.link/20261122082020.1255434-3-kaleshsingh@google.com
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Liam R. Howlett (Google) <liam@infradead.org>
Cc: Lokesh Gidra <lokeshgidra@google.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Peter Xu <peterx@redhat.com>
Cc: David Hildenbrand <david@kernel.org>
Cc: Lorenzo Stoakes <ljs@kernel.org>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Ryan Roberts <ryan.roberts@arm.com>

 tools/testing/selftests/mm/uffd-unit-tests.c |   42 ++++++++++++++---
 1 file changed, 37 insertions(+), 5 deletions(-)

--- a/tools/testing/selftests/mm/uffd-unit-tests.c~selftests-mm-uffd-unit-tests-filter-required-features-per-memory-type
+++ a/tools/testing/selftests/mm/uffd-unit-tests.c
@@ -176,15 +176,44 @@ out:
 }
 
 
-static bool uffd_feature_supported(uffd_test_case_t *test)
+/*
+ * Filter test->uffd_feature_required down to the features needed for @mem_type.
+ * For example, UFFD_FEATURE_WP_HUGETLBFS_SHMEM (gated on
+ * CONFIG_PTE_MARKER_UFFD_WP) only applies to shmem and hugetlbfs, so anonymous
+ * subtests should still run when it is absent.
+ */
+static uint64_t uffd_test_features(const uffd_test_case_t *test,
+				   const mem_type_t *mem_type)
+{
+	const uint64_t shmem = UFFD_FEATURE_MISSING_SHMEM |
+			       UFFD_FEATURE_MINOR_SHMEM;
+	const uint64_t hugetlb = UFFD_FEATURE_MISSING_HUGETLBFS |
+				 UFFD_FEATURE_MINOR_HUGETLBFS;
+	uint64_t features = test->uffd_feature_required;
+
+	switch (mem_type->mem_flag) {
+	case MEM_ANON:
+		return features & ~(shmem | hugetlb |
+				    UFFD_FEATURE_WP_HUGETLBFS_SHMEM);
+	case MEM_SHMEM:
+	case MEM_SHMEM_PRIVATE:
+		return features & ~hugetlb;
+	case MEM_HUGETLB:
+	case MEM_HUGETLB_PRIVATE:
+		return features & ~shmem;
+	default:
+		return features;
+	}
+}
+
+static bool uffd_feature_supported(uint64_t required)
 {
 	uint64_t features;
 
 	if (uffd_get_features(&features))
 		return false;
 
-	return (features & test->uffd_feature_required) ==
-	    test->uffd_feature_required;
+	return (features & required) == required;
 }
 
 static int pagemap_open(void)
@@ -2742,6 +2771,7 @@ uffd_test_case_t uffd_tests[] = {
 		.uffd_feature_required =
 		UFFD_FEATURE_MINOR_HUGETLBFS | UFFD_FEATURE_MINOR_SHMEM |
 		UFFD_FEATURE_PAGEFAULT_FLAG_WP |
+		UFFD_FEATURE_WP_HUGETLBFS_SHMEM |
 		/*
 		 * HACK: here we leveraged WP_UNPOPULATED to detect whether
 		 * minor mode supports wr-protect.  There's no feature flag
@@ -2961,6 +2991,7 @@ int main(int argc, char *argv[])
 	mem_type_t *mem_type;
 	uffd_test_args_t args;
 	const char *errmsg;
+	uint64_t features;
 	int i, j, opt;
 
 	while ((opt = getopt(argc, argv, "f:hl")) != -1) {
@@ -3036,11 +3067,12 @@ int main(int argc, char *argv[])
 			/* Initialize test arguments */
 			args.mem_type = mem_type;
 
-			if (!uffd_feature_supported(test)) {
+			features = uffd_test_features(test, mem_type);
+			if (!uffd_feature_supported(features)) {
 				uffd_test_skip("feature missing");
 				continue;
 			}
-			if (uffd_test_ctx_init(&gopts, test->uffd_feature_required, &errmsg)) {
+			if (uffd_test_ctx_init(&gopts, features, &errmsg)) {
 				uffd_test_skip(errmsg);
 				continue;
 			}
_

Patches currently in -mm which might be from kaleshsingh@google.com are

mm-swap-make-swap_header-badpages-a-flexible-array.patch
selftests-mm-uffd-wp-mremap-skip-unsupported-shmem-and-hugetlb-cases.patch
selftests-mm-uffd-unit-tests-filter-required-features-per-memory-type.patch


      parent reply	other threads:[~2026-11-24 23:34 UTC|newest]

Thread overview: 7+ 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 ` [PATCH 1/2] selftests/mm: uffd-wp-mremap: skip unsupported shmem and hugetlb cases kaleshsingh
2026-11-24 14:13   ` Liam R. Howlett
2026-11-24 23:34   ` + selftests-mm-uffd-wp-mremap-skip-unsupported-shmem-and-hugetlb-cases.patch added to mm-new branch Andrew Morton
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
2026-11-24 23:34   ` Andrew Morton [this message]

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=20261124233407.80CE51F000C6@smtp.kernel.org \
    --to=akpm@linux-foundation.org \
    --cc=david@kernel.org \
    --cc=kaleshsingh@google.com \
    --cc=liam@infradead.org \
    --cc=ljs@kernel.org \
    --cc=lokeshgidra@google.com \
    --cc=mhocko@suse.com \
    --cc=mm-commits@vger.kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.