Skip to content

Commit

Permalink
mm/hwpoison: retry with shake_page() for unhandlable pages
Browse files Browse the repository at this point in the history
HWPoisonHandlable() sometimes returns false for typical user pages due
to races with average memory events like transfers over LRU lists.  This
causes failures in hwpoison handling.

There's retry code for such a case but does not work because the retry
loop reaches the retry limit too quickly before the page settles down to
handlable state.  Let get_any_page() call shake_page() to fix it.

[[email protected]: get_any_page(): return -EIO when retry limit reached]
  Link: https://lkml.kernel.org/r/[email protected]

Link: https://lkml.kernel.org/r/[email protected]
Fixes: 25182f0 ("mm,hwpoison: fix race with hugetlb page allocation")
Signed-off-by: Naoya Horiguchi <[email protected]>
Reported-by: Tony Luck <[email protected]>
Reviewed-by: Yang Shi <[email protected]>
Cc: Oscar Salvador <[email protected]>
Cc: Muchun Song <[email protected]>
Cc: Mike Kravetz <[email protected]>
Cc: Michal Hocko <[email protected]>
Cc: <[email protected]>		[5.13+]
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
nhoriguchi authored and torvalds committed Aug 20, 2021
1 parent f56ce41 commit fcc0062
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions mm/memory-failure.c
Original file line number Diff line number Diff line change
Expand Up @@ -1146,7 +1146,7 @@ static int __get_hwpoison_page(struct page *page)
* unexpected races caused by taking a page refcount.
*/
if (!HWPoisonHandlable(head))
return 0;
return -EBUSY;

if (PageTransHuge(head)) {
/*
Expand Down Expand Up @@ -1199,9 +1199,15 @@ static int get_any_page(struct page *p, unsigned long flags)
}
goto out;
} else if (ret == -EBUSY) {
/* We raced with freeing huge page to buddy, retry. */
if (pass++ < 3)
/*
* We raced with (possibly temporary) unhandlable
* page, retry.
*/
if (pass++ < 3) {
shake_page(p, 1);
goto try_again;
}
ret = -EIO;
goto out;
}
}
Expand Down

0 comments on commit fcc0062

Please sign in to comment.