Skip to contentSkip to conversation

selftests-mm-test-fork-of-pmd-mapped-shmem-thps.patch removed from -mm tree

merged Andrew Morton 1 participant 1 message Nov 6

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: selftests/mm: test fork of PMD-mapped shmem THPs
has been removed from the -mm tree. Its filename was
selftests-mm-test-fork-of-pmd-mapped-shmem-thps.patch

This patch was dropped because it was merged into mainline or a subsystem tree

------------------------------------------------------
From: Konstantin Khorenko <[email protected]>
Subject: selftests/mm: test fork of PMD-mapped shmem THPs
Date: Wed, 04 Nov 2026 21:40:58 +0100

Fork a process that maps shmem THPs with PMDs, in a VMA whose page tables fork copies: a private mapping with an anon_vma, and a shared one with a guard region. The child must find the PMDs before it touches the mapping, and its exit must leave the parent's mapping and the system-wide ShmemPmdMapped counter as they were.

With folio_dup_file_rmap_pmd() adding PTE mappings, the child's exit takes the parent's share off ShmemPmdMapped while the parent still maps the folios. Unmapping them drops it once more, so every mapping stays until exit, where the kernel reports "Bad page cache", or hits a VM_BUG_ON with CONFIG_DEBUG_VM. A kernel that leaves file THPs to a refault in the child skips the test.

ShmemPmdMapped is system-wide, and reclaim or NUMA balancing can take a PMD from the parent while the test runs. So the test makes up to three attempts, each on a fresh file, and fails only if all of them see the counter drop by exactly the parent's share: the bug does that on every fork, other processes only by chance. It passes on the first clean attempt and skips when none is clean.

The test mounts a tmpfs with huge=always over /tmp in a private mount namespace, so it leaves the THP settings and the host's mounts and files alone.

Cc David Hildenbrand <[email protected]>
Cc Zi Yan <[email protected]>
Cc Baolin Wang <[email protected]>
Cc Liam R. Howlett <[email protected]>
Cc Nico Pache <[email protected]>
Cc Ryan Roberts <[email protected]>
Cc Dev Jain <[email protected]>
Cc Barry Song <[email protected]>
Cc Lance Yang <[email protected]>
Cc Usama Arif <[email protected]>
Cc Kiryl Shutsemau <[email protected]>
Cc Peter Xu <[email protected]>
Cc Alex Williamson <[email protected]>
Cc Loïc Molinari <[email protected]>
Cc Lorenzo Stoakes <[email protected]>
Cc Shuah Khan <[email protected]>
Cc Madhavan Srinivasan <[email protected]>
Cc Ritesh Harjani (IBM) <[email protected]>
Cc Jason Gunthorpe <[email protected]>
Cc "Jose A. Perez de Azpillaga" <[email protected]>

---

 MAINTAINERS                                |    1 
 tools/testing/selftests/mm/Makefile        |    1 
 tools/testing/selftests/mm/fork_file_thp.c |  256 +++++++++++++++++++
 tools/testing/selftests/mm/run_vmtests.sh  |    1 
 4 files changed, 259 insertions(+)
MAINTAINERS renamed from MAINTAINERS~selftests-mm-test-fork-of-pmd-mapped-shmem-thps +1 -0
@@ -17937,6 +17937,7 @@ F:	mm/huge_memory.c
 F:	mm/khugepaged.c
 F:	mm/mm_slot.h
 F:	tools/mm/thpmaps
+F:	tools/testing/selftests/mm/fork_file_thp.c
 F:	tools/testing/selftests/mm/khugepaged.c
 F:	tools/testing/selftests/mm/split_huge_page_test.c
 F:	tools/testing/selftests/mm/transhuge-stress.c
tools/testing/selftests/mm/fork_file_thp.c new file +256 -0

256 lines not on this page · raw message

tools/testing/selftests/mm/Makefile renamed from tools/testing/selftests/mm/Makefile~selftests-mm-test-fork-of-pmd-mapped-shmem-thps +1 -0
@@ -109,6 +109,7 @@ TEST_GEN_FILES += folio_split_race_test
 TEST_GEN_FILES += folio_order_check
 TEST_GEN_FILES += khugepaged_sync_check
 TEST_GEN_FILES += khugepaged_race
+TEST_GEN_FILES += fork_file_thp
 TEST_GEN_FILES += soft-dirty
 
 ifeq ($(ARCH),x86_64)
tools/testing/selftests/mm/run_vmtests.sh renamed from tools/testing/selftests/mm/run_vmtests.sh~selftests-mm-test-fork-of-pmd-mapped-shmem-thps +1 -0
@@ -451,6 +451,7 @@ fi
 CATEGORY="thp" run_test ./transhuge-stress -d 20
 
 CATEGORY="thp" run_test ./folio_split_race_test
+CATEGORY="thp" run_test ./fork_file_thp
 
 CATEGORY="migration" run_test ./migration
 

_

Patches currently in -mm which might be from [email protected] are