Commit 2af8ff29 authored by Hugh Dickins's avatar Hugh Dickins Committed by Linus Torvalds

mm/khugepaged: collapse_shmem() remember to clear holes

Huge tmpfs testing reminds us that there is no __GFP_ZERO in the gfp
flags khugepaged uses to allocate a huge page - in all common cases it
would just be a waste of effort - so collapse_shmem() must remember to
clear out any holes that it instantiates.

The obvious place to do so, where they are put into the page cache tree,
is not a good choice: because interrupts are disabled there.  Leave it
until further down, once success is assured, where the other pages are
copied (before setting PageUptodate).

Fixes: f3f0e1d2 ("khugepaged: add support of collapse for tmpfs/shmem pages")
Signed-off-by: default avatarHugh Dickins <>
Acked-by: default avatarKirill A. Shutemov <>
Cc: Jerome Glisse <>
Cc: Konstantin Khlebnikov <>
Cc: Matthew Wilcox <>
Cc: <>	[4.8+]
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent aaa52e34
......@@ -1467,7 +1467,12 @@ static void collapse_shmem(struct mm_struct *mm,
* Replacing old pages with new one has succeeded, now we
* need to copy the content and free the old pages.
index = start;
list_for_each_entry_safe(page, tmp, &pagelist, lru) {
while (index < page->index) {
clear_highpage(new_page + (index % HPAGE_PMD_NR));
copy_highpage(new_page + (page->index % HPAGE_PMD_NR),
......@@ -1477,6 +1482,11 @@ static void collapse_shmem(struct mm_struct *mm,
while (index < end) {
clear_highpage(new_page + (index % HPAGE_PMD_NR));
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment