From: Kirill A. Shutemov Date: Fri, 27 May 2016 21:27:38 +0000 (-0700) Subject: mm: thp: avoid false positive VM_BUG_ON_PAGE in page_move_anon_rmap() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=0798d3c022dc;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git mm: thp: avoid false positive VM_BUG_ON_PAGE in page_move_anon_rmap() If 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. Link: http://lkml.kernel.org/r/1464253620-106404-1-git-send-email-kirill.shutemov@linux.intel.com Fixes: 6d0a07edd17c ("mm: thp: calculate the mapcount correctly for THP pages during WP faults") Signed-off-by: Kirill A. Shutemov Reported-by: Mika Westerberg Tested-by: Mika Westerberg Reviewed-by: Andrea Arcangeli Cc: [4.5] Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/rmap.c b/mm/rmap.c index 8a839935b18c..0ea5d9071b32 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -1098,6 +1098,8 @@ void page_move_anon_rmap(struct page *page, VM_BUG_ON_PAGE(!PageLocked(page), page); VM_BUG_ON_VMA(!anon_vma, vma); + if (IS_ENABLED(CONFIG_DEBUG_VM) && PageTransHuge(page)) + address &= HPAGE_PMD_MASK; VM_BUG_ON_PAGE(page->index != linear_page_index(vma, address), page); anon_vma = (void *) anon_vma + PAGE_MAPPING_ANON;