mm/hwpoison: Retry with shake_page() for unhandlable pages
Subsystems (2)
PATCH v2 1/1 mm/hwpoison: Retry with shake_page() for unhandlable pages
From: Naoya Horiguchi <[email protected]>
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.
---
ChangeLog v2:
- get_any_page() return -EIO when retry limit reached (by Yang Shi)
--- mm/memory-failure.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
mm/memory-failure.c +9 -3
@@ -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)) {/*
@@ -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; } }
Signature · 1 line
2.25.1
Quoted 11 lines · Naoya Horiguchi
From: Naoya Horiguchi <[email protected]>
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()callshake_page()to fix it.
Quoted 7 lines
Fixes 25182f05ffed ("mm,hwpoison: fix race with hugetlb page allocation")Reported-by Tony Luck <[email protected]>Signed-off-by Naoya Horiguchi <[email protected]>Cc [email protected] # 5.13---
ChangeLog v2:
-get_any_page()return-EIOwhen retry limit reached (by Yang Shi)
Thanks for taking this. The fix looks good to me. Reviewed-by: Yang Shi <[email protected]>
Quoted 39 lines
--- mm/memory-failure.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)mm/memory-failure.c +9
-4@@ -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)) {/* @@ -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; } } --2.25.1