Thread (8 messages) 8 messages, 2 authors, 2024-04-29
STALE760d

[PATCH 2/2] mm/selftests: Don't prefault in gup_longterm tests

From: Peter Xu <peterx@redhat.com>
Date: 2024-04-28 19:01:59
Also in: linux-mm, lkml
Subsystem: kernel selftest framework, memory management - gup (get user pages), memory management - misc, the rest · Maintainers: Shuah Khan, Andrew Morton, David Hildenbrand, Linus Torvalds

Prefault, especially with RW, makes the GUP test too easy, and may not yet
reach the core of the test.

For example, R/O longterm pins will just hit, pte_write()==true for
whatever cases, the unsharing logic won't be ever tested.

This patch remove the prefault.  This tortures more code paths at least to
cover the unshare care for R/O longterm pins, in which case the first R/O
GUP attempt will fault in the page R/O first, then the 2nd will go through
the unshare path, checking whether an unshare is needed.

Cc: David Hildenbrand <redacted>
Signed-off-by: Peter Xu <peterx@redhat.com>
---
 tools/testing/selftests/mm/gup_longterm.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/mm/gup_longterm.c b/tools/testing/selftests/mm/gup_longterm.c
index ad168d35b23b..488e32186246 100644
--- a/tools/testing/selftests/mm/gup_longterm.c
+++ b/tools/testing/selftests/mm/gup_longterm.c
@@ -119,10 +119,16 @@ static void do_test(int fd, size_t size, enum test_type type, bool shared)
 	}
 
 	/*
-	 * Fault in the page writable such that GUP-fast can eventually pin
-	 * it immediately.
+	 * Explicitly avoid pre-faulting in the page, this can help testing
+	 * more code paths.
+	 *
+	 * Take example of an upcoming R/O pin test, if we RW prefault the
+	 * page, such pin will directly skip R/O unsharing and the longterm
+	 * pin will success mostly always.  When not prefaulted, R/O
+	 * longterm pin will first fault in a RO page, then the 2nd round
+	 * it'll go via the unshare check.  Otherwise those paths aren't
+	 * covered.
 	 */
-	memset(mem, 0, size);
 
 	switch (type) {
 	case TEST_TYPE_RO:
-- 
2.44.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help