Commit 906d278d authored by William Kucharski's avatar William Kucharski Committed by Linus Torvalds

mm/vmscan.c: support removing arbitrary sized pages from mapping

__remove_mapping() assumes that pages can only be either base pages or
HPAGE_PMD_SIZE.  Ask the page what size it is.

Link: http://lkml.kernel.org/r/20191017164223.2762148-4-songliubraving@fb.com
Fixes: 99cb0dbd ("mm,thp: add read-only THP support for (non-shmem) FS")
Signed-off-by: default avatarWilliam Kucharski <william.kucharski@oracle.com>
Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: default avatarSong Liu <songliubraving@fb.com>
Acked-by: default avatarYang Shi <yang.shi@linux.alibaba.com>
Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 06d3eff6
...@@ -933,10 +933,7 @@ static int __remove_mapping(struct address_space *mapping, struct page *page, ...@@ -933,10 +933,7 @@ static int __remove_mapping(struct address_space *mapping, struct page *page,
* Note that if SetPageDirty is always performed via set_page_dirty, * Note that if SetPageDirty is always performed via set_page_dirty,
* and thus under the i_pages lock, then this ordering is not required. * and thus under the i_pages lock, then this ordering is not required.
*/ */
if (unlikely(PageTransHuge(page)) && PageSwapCache(page)) refcount = 1 + compound_nr(page);
refcount = 1 + HPAGE_PMD_NR;
else
refcount = 2;
if (!page_ref_freeze(page, refcount)) if (!page_ref_freeze(page, refcount))
goto cannot_free; goto cannot_free;
/* note: atomic_cmpxchg in page_ref_freeze provides the smp_rmb */ /* note: atomic_cmpxchg in page_ref_freeze provides the smp_rmb */
......
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