Skip to contentSkip to conversation

selftests-vm-add-file-shmem-madv_collapse-selftest-for-cleared-pmd.patch removed from -mm tree

merged mm-stable Andrew Morton 1 participant 1 message Oct 3, 2022

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: selftests/vm: add file/shmem MADV_COLLAPSE selftest for cleared pmd
has been removed from the -mm tree. Its filename was
selftests-vm-add-file-shmem-madv_collapse-selftest-for-cleared-pmd.patch

This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: "Zach O'Keefe" <[email protected]>
Subject: selftests/vm: add file/shmem MADV_COLLAPSE selftest for cleared pmd
Date: Thu, 22 Sep 2022 15:40:45 -0700

This test tests that MADV_COLLAPSE acting on file/shmem memory for which
(1) the file extent mapping by the memory is already a huge page in the page cache, and (2) the pmd mapping this memory in the target process is none.

In practice, (1)+(2) is the state left over after khugepaged has successfully collapsed file/shmem memory for a target VMA, but the memory has not yet been refaulted. So, this test in-effect tests MADV_COLLAPSE racing with khugepaged to collapse the memory first.

Cc Axel Rasmussen <[email protected]>
Cc Chris Kennelly <[email protected]>
Cc David Hildenbrand <[email protected]>
Cc David Rientjes <[email protected]>
Cc Hugh Dickins <[email protected]>
Cc James Houghton <[email protected]>
Cc "Kirill A. Shutemov" <[email protected]>
Cc Matthew Wilcox <[email protected]>
Cc Miaohe Lin <[email protected]>
Cc Minchan Kim <[email protected]>
Cc Pasha Tatashin <[email protected]>
Cc Peter Xu <[email protected]>
Cc Rongwei Wang <[email protected]>
Cc SeongJae Park <[email protected]>
Cc Song Liu <[email protected]>
Cc Vlastimil Babka <[email protected]>
Cc Yang Shi <[email protected]>

---

 tools/testing/selftests/vm/khugepaged.c |   30 ++++++++++++++++++++++
 1 file changed, 30 insertions(+)
tools/testing/selftests/vm/khugepaged.c renamed from tools/testing/selftests/vm/khugepaged.c~selftests-vm-add-file-shmem-madv_collapse-selftest-for-cleared-pmd +30 -0
@@ -1353,6 +1353,33 @@ static void madvise_collapse_existing_th
 	ops->cleanup_area(p, hpage_pmd_size);
 }
 
+/*
+ * Test race with khugepaged where page tables have been retracted and
+ * pmd cleared.
+ */
+static void madvise_retracted_page_tables(struct collapse_context *c,
+					  struct mem_ops *ops)
+{
+	void *p;
+	int nr_hpages = 1;
+	unsigned long size = nr_hpages * hpage_pmd_size;
+
+	p = ops->setup_area(nr_hpages);
+	ops->fault(p, 0, size);
+
+	/* Let khugepaged collapse and leave pmd cleared */
+	if (wait_for_scan("Collapse and leave PMD cleared", p, nr_hpages,
+			  ops)) {
+		fail("Timeout");
+		return;
+	}
+	success("OK");
+	c->collapse("Install huge PMD from page cache", p, nr_hpages, ops,
+		    true);
+	validate_memory(p, 0, size);
+	ops->cleanup_area(p, size);
+}
+
 static void usage(void)
 {
 	fprintf(stderr, "\nUsage: ./khugepaged <test type> [dir]\n\n");
@@ -1524,5 +1551,8 @@ int main(int argc, const char **argv)
 	TEST(madvise_collapse_existing_thps, madvise_context, file_ops);
 	TEST(madvise_collapse_existing_thps, madvise_context, shmem_ops);
 
+	TEST(madvise_retracted_page_tables, madvise_context, file_ops);
+	TEST(madvise_retracted_page_tables, madvise_context, shmem_ops);
+
 	restore_settings(0);
 }

_

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