Skip to content

Commit

Permalink
mm/memory-failure: give up error handling for non-tail-refcounted thp
Browse files Browse the repository at this point in the history
"non anonymous thp" case is still racy with freeing thp, which causes
panic due to put_page() for refcount-0 page.  It seems that closing up
this race might be hard (and/or not worth doing,) so let's give up the
error handling for this case.

Signed-off-by: Naoya Horiguchi <[email protected]>
Cc: Andi Kleen <[email protected]>
Cc: Dean Nelson <[email protected]>
Cc: Tony Luck <[email protected]>
Cc: "Kirill A. Shutemov" <[email protected]>
Cc: Hugh Dickins <[email protected]>
Cc: David Rientjes <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Naoya Horiguchi authored and torvalds committed Aug 7, 2015
1 parent a209ef0 commit 98ed2b0
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions mm/memory-failure.c
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,18 @@ int get_hwpoison_page(struct page *page)
* directly for tail pages.
*/
if (PageTransHuge(head)) {
/*
* Non anonymous thp exists only in allocation/free time. We
* can't handle such a case correctly, so let's give it up.
* This should be better than triggering BUG_ON when kernel
* tries to touch the "partially handled" page.
*/
if (!PageAnon(head)) {
pr_err("MCE: %#lx: non anonymous thp\n",
page_to_pfn(page));
return 0;
}

if (get_page_unless_zero(head)) {
if (PageTail(page))
get_page(page);
Expand Down Expand Up @@ -1134,15 +1146,6 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
}

if (!PageHuge(p) && PageTransHuge(hpage)) {
if (!PageAnon(hpage)) {
pr_err("MCE: %#lx: non anonymous thp\n", pfn);
if (TestClearPageHWPoison(p))
atomic_long_sub(nr_pages, &num_poisoned_pages);
put_page(p);
if (p != hpage)
put_page(hpage);
return -EBUSY;
}
if (unlikely(split_huge_page(hpage))) {
pr_err("MCE: %#lx: thp split failed\n", pfn);
if (TestClearPageHWPoison(p))
Expand Down

0 comments on commit 98ed2b0

Please sign in to comment.