Skip to content

Commit 98ed2b0

Browse files
Naoya Horiguchitorvalds
authored andcommitted
mm/memory-failure: give up error handling for non-tail-refcounted thp
"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]>
1 parent a209ef0 commit 98ed2b0

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

mm/memory-failure.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,18 @@ int get_hwpoison_page(struct page *page)
909909
* directly for tail pages.
910910
*/
911911
if (PageTransHuge(head)) {
912+
/*
913+
* Non anonymous thp exists only in allocation/free time. We
914+
* can't handle such a case correctly, so let's give it up.
915+
* This should be better than triggering BUG_ON when kernel
916+
* tries to touch the "partially handled" page.
917+
*/
918+
if (!PageAnon(head)) {
919+
pr_err("MCE: %#lx: non anonymous thp\n",
920+
page_to_pfn(page));
921+
return 0;
922+
}
923+
912924
if (get_page_unless_zero(head)) {
913925
if (PageTail(page))
914926
get_page(page);
@@ -1134,15 +1146,6 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
11341146
}
11351147

11361148
if (!PageHuge(p) && PageTransHuge(hpage)) {
1137-
if (!PageAnon(hpage)) {
1138-
pr_err("MCE: %#lx: non anonymous thp\n", pfn);
1139-
if (TestClearPageHWPoison(p))
1140-
atomic_long_sub(nr_pages, &num_poisoned_pages);
1141-
put_page(p);
1142-
if (p != hpage)
1143-
put_page(hpage);
1144-
return -EBUSY;
1145-
}
11461149
if (unlikely(split_huge_page(hpage))) {
11471150
pr_err("MCE: %#lx: thp split failed\n", pfn);
11481151
if (TestClearPageHWPoison(p))

0 commit comments

Comments
 (0)