Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mm: thp: check total_mapcount instead of page_mapcount
When debugging the bug reported by Wang Yugui [1], try_to_unmap() may return false positive for PTE-mapped THP since page_mapcount() is used to check if the THP is unmapped, but it just checks compound mapcount and head page's mapcount. If the THP is PTE-mapped and head page is not mapped, it may return a false positive. Use total_mapcount() instead of page_mapcount() for try_to_unmap() and do so for the VM_BUG_ON_PAGE in split_huge_page_to_list as well. This changes the semantics of try_to_unmap(), but I don't see there is any use case that expects try_to_unmap() to just unmap one subpage of a huge page. So using page_mapcount() seems like a bug. [1] https://lore.kernel.org/linux-mm/[email protected]/ Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Yang Shi <[email protected]> Cc: Zi Yan <[email protected]> Cc: Kirill A. Shutemov <[email protected]> Cc: Wang Yugui <[email protected]> Cc: Hugh Dickins <[email protected]> Cc: Mike Kravetz <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Stephen Rothwell <[email protected]>
- Loading branch information