[PATCH v5 2/3] selftests/mm: skip the mkdirty ptrace write tests without FOLL_FORCE

From: Nikolai Dokutovich

Date: Tue Dec 01 2026 - 14:17:05 EST


Both ptrace write tests fail when the kernel does not allow forced writes:

not ok 1 write() failed

Check the permission at their entry and skip instead. The other subtests
do not depend on it and keep running.

Signed-off-by: Nikolai Dokutovich <ndokutovich@xxxxxxxxx>
---
tools/testing/selftests/mm/mkdirty.c | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/tools/testing/selftests/mm/mkdirty.c b/tools/testing/selftests/mm/mkdirty.c
index 68dd447a5454..f6f50016cf5c 100644
--- a/tools/testing/selftests/mm/mkdirty.c
+++ b/tools/testing/selftests/mm/mkdirty.c
@@ -91,6 +91,11 @@ static void test_ptrace_write(void)

ksft_print_msg("[INFO] PTRACE write access\n");

+ if (!proc_mem_force_write_allowed()) {
+ ksft_test_result_skip("FOLL_FORCE write not available\n");
+ return;
+ }
+
mem = mmap(NULL, pagesize, PROT_READ, MAP_PRIVATE|MAP_ANON, -1, 0);
if (mem == MAP_FAILED) {
ksft_test_result_fail("mmap() failed\n");
@@ -128,6 +133,11 @@ static void test_ptrace_write_thp(void)

ksft_print_msg("[INFO] PTRACE write access to THP\n");

+ if (!proc_mem_force_write_allowed()) {
+ ksft_test_result_skip("FOLL_FORCE write not available\n");
+ return;
+ }
+
mem = mmap_thp_range(PROT_READ, &mmap_mem, &mmap_size);
if (mem == MAP_FAILED)
return;
--
2.43.0