Skip to content

Commit

Permalink
mm/thp: allow dropping THP from page cache
Browse files Browse the repository at this point in the history
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/20191017164223.2762148-5-songliubraving@fb.com
Fixes: 99cb0db ("mm,thp: add read-only THP support for (non-shmem) FS")
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Signed-off-by: Song Liu <songliubraving@fb.com>
Tested-by: Song Liu <songliubraving@fb.com>
Acked-by: Yang Shi <yang.shi@linux.alibaba.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: William Kucharski <william.kucharski@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Kirill A. Shutemov authored and Linus Torvalds committed Oct 19, 2019
1 parent 906d278 commit ef18a1c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions mm/truncate.c
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,16 @@ unsigned long invalidate_mapping_pages(struct address_space *mapping,
unlock_page(page);
continue;
}

/* Take a pin outside pagevec */
get_page(page);

/*
* Drop extra pins before trying to invalidate
* the huge page.
*/
pagevec_remove_exceptionals(&pvec);
pagevec_release(&pvec);
}

ret = invalidate_inode_page(page);
Expand All @@ -602,6 +612,8 @@ unsigned long invalidate_mapping_pages(struct address_space *mapping,
*/
if (!ret)
deactivate_file_page(page);
if (PageTransHuge(page))
put_page(page);
count += ret;
}
pagevec_remove_exceptionals(&pvec);
Expand Down

0 comments on commit ef18a1c

Please sign in to comment.