Skip to content

Commit ef18a1c

Browse files
kiryltorvalds
authored andcommitted
mm/thp: allow dropping THP from page cache
Once a THP is added to the page cache, it cannot be dropped via /proc/sys/vm/drop_caches. Fix this issue with proper handling in invalidate_mapping_pages(). Link: http://lkml.kernel.org/r/[email protected] Fixes: 99cb0db ("mm,thp: add read-only THP support for (non-shmem) FS") Signed-off-by: Kirill A. Shutemov <[email protected]> Signed-off-by: Song Liu <[email protected]> Tested-by: Song Liu <[email protected]> Acked-by: Yang Shi <[email protected]> Cc: Matthew Wilcox (Oracle) <[email protected]> Cc: Oleg Nesterov <[email protected]> Cc: Srikar Dronamraju <[email protected]> Cc: William Kucharski <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 906d278 commit ef18a1c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

mm/truncate.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,16 @@ unsigned long invalidate_mapping_pages(struct address_space *mapping,
592592
unlock_page(page);
593593
continue;
594594
}
595+
596+
/* Take a pin outside pagevec */
597+
get_page(page);
598+
599+
/*
600+
* Drop extra pins before trying to invalidate
601+
* the huge page.
602+
*/
603+
pagevec_remove_exceptionals(&pvec);
604+
pagevec_release(&pvec);
595605
}
596606

597607
ret = invalidate_inode_page(page);
@@ -602,6 +612,8 @@ unsigned long invalidate_mapping_pages(struct address_space *mapping,
602612
*/
603613
if (!ret)
604614
deactivate_file_page(page);
615+
if (PageTransHuge(page))
616+
put_page(page);
605617
count += ret;
606618
}
607619
pagevec_remove_exceptionals(&pvec);

0 commit comments

Comments
 (0)