mm, hwpoison: do not lock page again when me_huge_page() successfully recovers
Subsystems (2)
Naoya Horiguchi
reviewerPATCH 1/1 mm, hwpoison: do not lock page again when me_huge_page() successfully recovers
From: Naoya Horiguchi <[email protected]>
Currently me_huge_page() temporary unlocks page to perform some actions then locks it again later. My testcase (which calls hard-offline on some tail page in a hugetlb, then accesses the address of the hugetlb range) showed that page allocation code detects the page lock on buddy page and printed out "BUG: Bad page state" message. PG_hwpoison does not prevent it because PG_hwpoison flag is set on any subpage of the hugetlb page but the 2nd page lock is on the head page.
This patch suggests to drop the 2nd page lock to fix the issue.
--- mm/memory-failure.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
mm/memory-failure.c +2 -2
@@ -830,7 +830,6 @@ static int me_huge_page(struct page *p, unsigned long pfn)page_ref_inc (p); res =MF_RECOVERED ; } -lock_page (hpage); }return res;
@@ -1286,7 +1285,8 @@ static int memory_failure_hugetlb(unsigned long pfn, int flags) res =identify_page_state (pfn, p, page_flags); out: -unlock_page (head); +if (PageLocked (head)) +unlock_page (head);return res; }
Signature · 1 line
2.25.1
Quoted 1 line · Naoya Horiguchi
From: Naoya Horiguchi <[email protected]>
Hi Naoya,
good catch!
Quoted 7 lines
Currently
me_huge_page()temporary unlocks page to perform some actions then locks it again later. My testcase (which calls hard-offline on some tail page in a hugetlb, then accesses the address of the hugetlb range) showed that page allocation code detects the page lock on buddy page and printed out "BUG: Bad page state" message.PG_hwpoisondoes not prevent it becausePG_hwpoisonflag is set on any subpage of the hugetlb page but the 2nd page lock is on the head page.
I am having difficulties to parse "PG_hwpoison does not prevent it because PG_hwpoison flag is set on any subpage of the hugetlb page".
What do you mean by that?
Quoted 6 lines
This patch suggests to drop the 2nd page lock to fix the issue.
Fixes commit 78bb920344b8 ("mm: hwpoison: dissolve in-use hugepage in unrecoverable memory error")Signed-off-by Naoya Horiguchi <[email protected]>
The fix looks fine to me:
Signature · 2 lines
Oscar Salvador SUSE L3
Naoya Horiguchi
reviewerPATCH v2 1/1 mm, hwpoison: do not lock page again when me_huge_page() successfully recovers
Hello Oscar,
Quoted 15 lines · Oscar Salvador
Quoted 1 line · Naoya Horiguchi
From: Naoya Horiguchi <[email protected]>
Hi Naoya,
good catch!
Quoted 7 lines
Currently
me_huge_page()temporary unlocks page to perform some actions then locks it again later. My testcase (which calls hard-offline on some tail page in a hugetlb, then accesses the address of the hugetlb range) showed that page allocation code detects the page lock on buddy page and printed out "BUG: Bad page state" message.PG_hwpoisondoes not prevent it becausePG_hwpoisonflag is set on any subpage of the hugetlb page but the 2nd page lock is on the head page.
Quoted 4 lines
I am having difficulties to parse "
PG_hwpoisondoes not prevent it becausePG_hwpoisonflag is set on any subpage of the hugetlb page".What do you mean by that?
What was in my mind is that check_new_page_bad() does not consider a page with __PG_HWPOISON as bad page, so this flag works as kind of filter, but this filtering doesn't work in my case because the "bad page" is not the actual hwpoisoned page.
Thank for nice comment, I've updated the patch below with this description.
Quoted 11 lines
Quoted 7 lines
This patch suggests to drop the 2nd page lock to fix the issue.
Fixes commit 78bb920344b8 ("mm: hwpoison: dissolve in-use hugepage in unrecoverable memory error")Signed-off-by Naoya Horiguchi <[email protected]>The fix looks fine to me:
Reviewed-by Oscar Salvador <[email protected]>
Thank you!
Have a nice weekend.
- Naoya
---
From eaaaab05750c13fe9b637190410289a3168b097e Mon Sep 17 00:00:00 2001
From: Naoya Horiguchi <[email protected]>
Date: Fri, 5 Mar 2021 21:44:47 +0900
Subject: [PATCH v2] mm, hwpoison: do not lock page again when me_huge_page()
successfully recovers
Currently me_huge_page() temporary unlocks page to perform some actions then locks it again later. My testcase (which calls hard-offline on some tail page in a hugetlb, then accesses the address of the hugetlb range) showed that page allocation code detects this page lock on buddy page and printed out "BUG: Bad page state" message.
check_new_page_bad() does not consider a page with __PG_HWPOISON as bad page, so this flag works as kind of filter, but this filtering doesn't work in this case because the "bad page" is not the actual hwpoisoned page.
This patch suggests to drop the 2nd page lock to fix the issue.
--- mm/memory-failure.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
mm/memory-failure.c +2 -2
@@ -830,7 +830,6 @@ static int me_huge_page(struct page *p, unsigned long pfn)page_ref_inc (p); res =MF_RECOVERED ; } -lock_page (hpage); }return res;
@@ -1286,7 +1285,8 @@ static int memory_failure_hugetlb(unsigned long pfn, int flags) res =identify_page_state (pfn, p, page_flags); out: -unlock_page (head); +if (PageLocked (head)) +unlock_page (head);return res; }
Signature · 1 line
2.25.1