diff mbox series

[v2,2/2] mm/memory-failure.c: dissolve truncated hugetlb page

Message ID 20220414114941.11223-3-linmiaohe@huawei.com (mailing list archive)
State New
Headers show
Series A few fixup and cleanup patches for memory failure | expand

Commit Message

Miaohe Lin April 14, 2022, 11:49 a.m. UTC
If me_huge_page meets a truncated but not yet freed hugepage, it won't be
dissolved even if we hold the last refcnt. It's because the hugepage has
NULL page_mapping while it's not anonymous hugepage too. Thus we lose the
last chance to dissolve it into buddy to save healthy subpages. Remove
PageAnon check to handle these hugepages too.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 mm/memory-failure.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

Comments

HORIGUCHI NAOYA(堀口 直也) April 15, 2022, 1:18 a.m. UTC | #1
On Thu, Apr 14, 2022 at 07:49:41PM +0800, Miaohe Lin wrote:
> If me_huge_page meets a truncated but not yet freed hugepage, it won't be
> dissolved even if we hold the last refcnt. It's because the hugepage has
> NULL page_mapping while it's not anonymous hugepage too. Thus we lose the
> last chance to dissolve it into buddy to save healthy subpages. Remove
> PageAnon check to handle these hugepages too.
> 
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>

Thank you for the update.

Acked-by: Naoya Horiguchi <naoya.horiguchi@nec.com>
diff mbox series

Patch

diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 488aaca72340..1d64bfff339d 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -1041,12 +1041,11 @@  static int me_huge_page(struct page_state *ps, struct page *p)
 		res = MF_FAILED;
 		unlock_page(hpage);
 		/*
-		 * migration entry prevents later access on error anonymous
-		 * hugepage, so we can free and dissolve it into buddy to
-		 * save healthy subpages.
+		 * migration entry prevents later access on error hugepage,
+		 * so we can free and dissolve it into buddy to save healthy
+		 * subpages.
 		 */
-		if (PageAnon(hpage))
-			put_page(hpage);
+		put_page(hpage);
 		if (__page_handle_poison(p)) {
 			page_ref_inc(p);
 			res = MF_RECOVERED;