path: root/fs
diff options
authorSong Liu <>2019-09-23 15:38:30 -0700
committerLinus Torvalds <>2019-09-24 15:54:11 -0700
commit27e1f8273113adec0e98bf513e4091636b27cc2a (patch)
treecd1f81f4765ab885b2ed04d178691c4ed9c7845b /fs
parent5a52c9df62b422087d0c88fc79641028e4472a3b (diff)
khugepaged: enable collapse pmd for pte-mapped THP
khugepaged needs exclusive mmap_sem to access page table. When it fails to lock mmap_sem, the page will fault in as pte-mapped THP. As the page is already a THP, khugepaged will not handle this pmd again. This patch enables the khugepaged to retry collapse the page table. struct mm_slot (in khugepaged.c) is extended with an array, containing addresses of pte-mapped THPs. We use array here for simplicity. We can easily replace it with more advanced data structures when needed. In khugepaged_scan_mm_slot(), if the mm contains pte-mapped THP, we try to collapse the page table. Since collapse may happen at an later time, some pages may already fault in. collapse_pte_mapped_thp() is added to properly handle these pages. collapse_pte_mapped_thp() also double checks whether all ptes in this pmd are mapping to the same THP. This is necessary because some subpage of the THP may be replaced, for example by uprobe. In such cases, it is not possible to collapse the pmd. [ add comments for retract_page_tables()] Link: Link: Signed-off-by: Song Liu <> Signed-off-by: Kirill A. Shutemov <> Acked-by: Kirill A. Shutemov <> Suggested-by: Johannes Weiner <> Reviewed-by: Oleg Nesterov <> Signed-off-by: Andrew Morton <> Signed-off-by: Linus Torvalds <>
Diffstat (limited to 'fs')
0 files changed, 0 insertions, 0 deletions