Commit 770a5370 authored by Gerald Schaefer's avatar Gerald Schaefer Committed by Linus Torvalds

mm: thp: broken page count after commit aa88b68c

Christian Borntraeger reported a kernel panic after corrupt page counts,
and it turned out to be a regression introduced with commit aa88b68c
("thp: keep huge zero page pinned until tlb flush"), at least on s390.

put_huge_zero_page() was moved over from zap_huge_pmd() to
release_pages(), and it was replaced by tlb_remove_page().  However,
release_pages() might not always be triggered by (the arch-specific)

On s390 we call free_page_and_swap_cache() from tlb_remove_page(), and
not tlb_flush_mmu() -> free_pages_and_swap_cache() like the generic
version, because we don't use the MMU-gather logic.  Although both
functions have very similar names, they are doing very unsimilar things,
in particular free_page_xxx is just doing a put_page(), while
free_pages_xxx calls release_pages().

This of course results in very harmful put_page()s on the huge zero
page, on architectures where tlb_remove_page() is implemented in this
way.  It seems to affect only s390 and sh, but sh doesn't have THP
support, so the problem (currently) probably only exists on s390.

The following quick hack fixed the issue:

Link: default avatarGerald Schaefer <>
Reported-by: default avatarChristian Borntraeger <>
Tested-by: default avatarChristian Borntraeger <>
Cc: "Kirill A. Shutemov" <>
Cc: Andrea Arcangeli <>
Cc: "Aneesh Kumar K.V" <>
Cc: Mel Gorman <>
Cc: Hugh Dickins <>
Cc: Johannes Weiner <>
Cc: Dave Hansen <>
Cc: Vlastimil Babka <>
Cc: Martin Schwidefsky <>
Cc: Heiko Carstens <>
Cc: <>	[4.6.x]
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent d0db7afa
......@@ -252,7 +252,10 @@ static inline void free_swap_cache(struct page *page)
void free_page_and_swap_cache(struct page *page)
if (is_huge_zero_page(page))
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