[PATCH 1/1] mm: thp: avoid false positive VM_BUG_ON_PAGE in page_move_anon_rmap()

From: Andrea Arcangeli
Date: Mon May 23 2016 - 11:03:57 EST


If the page_move_anon_rmap() is refiling a pmd-splitted THP mapped in
a tail page from a pte, the "address" must be THP aligned in order for
the page->index bugcheck to pass in the CONFIG_DEBUG_VM=y builds.

Signed-off-by: Andrea Arcangeli <aarcange@xxxxxxxxxx>
---
mm/rmap.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/mm/rmap.c b/mm/rmap.c
index 8a83993..e2e47ba9 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -1098,7 +1098,10 @@ void page_move_anon_rmap(struct page *page,

VM_BUG_ON_PAGE(!PageLocked(page), page);
VM_BUG_ON_VMA(!anon_vma, vma);
- VM_BUG_ON_PAGE(page->index != linear_page_index(vma, address), page);
+ VM_BUG_ON_PAGE(page->index !=
+ linear_page_index(vma, PageTransHuge(page) ?
+ address & HPAGE_PMD_MASK :
+ address), page);

anon_vma = (void *) anon_vma + PAGE_MAPPING_ANON;
/*