Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v5 0/3] selftests/mm: skip tests when FOLL_FORCE writes are not available
@ 2026-12-01 19:16 Nikolai Dokutovich
  2026-12-01 19:16 ` [PATCH v5 1/3] selftests/mm: add a probe for FOLL_FORCE writes through /proc/self/mem Nikolai Dokutovich
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Nikolai Dokutovich @ 2026-12-01 19:16 UTC (permalink / raw)
  To: David Hildenbrand, Andrew Morton
  Cc: Shuah Khan, Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
	Michal Hocko, Xu Xin, linux-mm, linux-kselftest, linux-kernel,
	Nikolai Dokutovich

A write through /proc/self/mem into a mapping that is not writable needs
FOLL_FORCE, which CONFIG_PROC_MEM_FORCE_PTRACE only grants to a caller that
traces the target.  mkdirty and the ksm PROT_NONE test then fail instead of
skipping on a distribution kernel:

    not ok 1 write() failed
    not ok 5 ptrace write failed

Add a probe that performs the same write on a scratch mapping, and skip the
affected tests when it does not succeed.  mm/config already asks for
CONFIG_PROC_MEM_ALWAYS_FORCE=y for harness runs; this covers binaries run
on kernels built without it.

Tested on x86_64 with a kernel whose .config has
CONFIG_PROC_MEM_FORCE_PTRACE=y, CONFIG_CHECKPOINT_RESTORE=n,
CONFIG_USERFAULTFD=n, CONFIG_KSM=y:

  default boot                        mkdirty pass:3 skip:3
                                      ksm     pass:8 skip:2
  proc_mem.force_override=always      mkdirty pass:5 skip:1
                                      ksm     pass:9 skip:1

Changes in v5 (relative to v3; v4 was retracted):
 - Drop the inconclusive branch; the probe returns a plain bool.
 - Shorten the comment and the commit messages.
 - Skip with "FOLL_FORCE write not available".


Nikolai Dokutovich (3):
  selftests/mm: add a probe for FOLL_FORCE writes through /proc/self/mem
  selftests/mm: skip the mkdirty ptrace write tests without FOLL_FORCE
  selftests/mm: skip the ksm PROT_NONE test without FOLL_FORCE

 .../selftests/mm/ksm_functional_tests.c       |  5 ++++
 tools/testing/selftests/mm/mkdirty.c          | 10 +++++++
 tools/testing/selftests/mm/vm_util.c          | 29 +++++++++++++++++++
 tools/testing/selftests/mm/vm_util.h          |  8 +++++
 4 files changed, 52 insertions(+)

-- 
2.43.0



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-12-01 19:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01 19:16 [PATCH v5 0/3] selftests/mm: skip tests when FOLL_FORCE writes are not available Nikolai Dokutovich
2026-12-01 19:16 ` [PATCH v5 1/3] selftests/mm: add a probe for FOLL_FORCE writes through /proc/self/mem Nikolai Dokutovich
2026-12-01 19:16 ` [PATCH v5 2/3] selftests/mm: skip the mkdirty ptrace write tests without FOLL_FORCE Nikolai Dokutovich
2026-12-01 19:16 ` [PATCH v5 3/3] selftests/mm: skip the ksm PROT_NONE test " Nikolai Dokutovich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox