Skip to content

Commit

Permalink
mm/khugepaged.c: convert VM_BUG_ON() to collapse fail
Browse files Browse the repository at this point in the history
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.

Link: http://lkml.kernel.org/r/[email protected]
Fixes: b1caa95 ("khugepaged: ignore pmd tables with THP mapped with ptes")
Signed-off-by: Kirill A. Shutemov <[email protected]>
Cc: Laura Abbott <[email protected]>
Cc: Jerome Marchand <[email protected]>
Cc: Vlastimil Babka <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
kiryl authored and torvalds committed Mar 23, 2018
1 parent 28ee90f commit fece202
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion mm/khugepaged.c
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,12 @@ static int __collapse_huge_page_isolate(struct vm_area_struct *vma,
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);

/*
Expand Down

0 comments on commit fece202

Please sign in to comment.