Skip to contentSkip to conversation

mm/khugepaged.c: convert VM_BUG_ON() to collapse fail

PATCH In review [email protected] 1 participant 1 message Mar 22, 2018

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 8/13 mm/khugepaged.c: convert VM_BUG_ON() to collapse fail

From: "Kirill A. Shutemov" <[email protected]>
Subject: mm/khugepaged.c: convert VM_BUG_ON() to collapse fail

khugepaged is not yet able to convert PTE-mapped huge pages back to PMD mapped. We do not collapse such pages. See check khugepaged_scan_pmd().

But if between khugepaged_scan_pmd() and __collapse_huge_page_isolate() somebody managed to instantiate THP in the range and then split the PMD back to PTEs we would have a problem -- VM_BUG_ON_PAGE(PageCompound(page)) will get triggered.

It's possible since we drop mmap_sem during collapse to re-take for write.

Replace the VM_BUG_ON() with graceful collapse fail.

Fixes b1caa957ae6d ("khugepaged: ignore pmd tables with THP mapped with ptes")
Cc Laura Abbott <[email protected]>
Cc Jerome Marchand <[email protected]>
Cc Vlastimil Babka <[email protected]>
Signed-off-by Andrew Morton <>

---

 mm/khugepaged.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
mm/khugepaged.c renamed from mm/khugepaged.c~mm-khugepaged-convert-vm_bug_on-to-collapse-fail +6 -1
diff -puN mm/khugepaged.c~mm-khugepaged-convert-vm_bug_on-to-collapse-fail mm/khugepaged.c
@@ -530,7 +530,12 @@ static int __collapse_huge_page_isolate(
 			goto out;
 		}
 
-		VM_BUG_ON_PAGE(PageCompound(page), page);
+		/* TODO: teach khugepaged to collapse THP mapped with pte */
+		if (PageCompound(page)) {
+			result = SCAN_PAGE_COMPOUND;
+			goto out;
+		}
+
 		VM_BUG_ON_PAGE(!PageAnon(page), page);
 
 		/*

_