Skip to contentSkip to conversation

A few fixup and cleanup patches for memory failure

PATCH Superseded Miaohe Lin 2 participants 4 messages Apr 14, 2022 – Apr 15, 2022

Subsystems (2)

v2 of 3 Superseded 1 of 2 applied Latest is v3 →

lore
Share & tools
lore

Miaohe Lin

author maintainer
#0 lore raw

v2 cover A few fixup and cleanup patches for memory failure

Hi everyone,
This series contains a patch to clean up the HWPoisonHandlable and another one to dissolve truncated hugetlb page. More details can be found in the respective changelogs. Thanks!

---
v2:
drop patch "mm/memory-failure.c: avoid false-postive PageSwapCache test" collect Reviewed-by and Acked-by tag.
update the comment and enhance the commit log for "mm/memory-failure.c:
dissolve truncated hugetlb page"
Thanks David, Yang Shi and Naoya for review!
---
Miaohe Lin (2):
mm/memory-failure.c: minor cleanup for HWPoisonHandlable mm/memory-failure.c: dissolve truncated hugetlb page

 mm/memory-failure.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)
Signature · 1 line
2.23.0
author maintainer
#1 lore raw

PATCH v2 1/2 mm/memory-failure.c: minor cleanup for HWPoisonHandlable

The local variable movable can be removed by returning true directly. Also fix typo 'mirgate'. No functional change intended.

---
 mm/memory-failure.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
mm/memory-failure.c +3 -5
index e3fbff5bd467..488aaca72340 100644
@@ -1179,13 +1179,11 @@ void ClearPageHWPoisonTakenOff(struct page *page)
  */
 static inline bool HWPoisonHandlable(struct page *page, unsigned long flags)
 {
-	bool movable = false;
-
-	/* Soft offline could mirgate non-LRU movable pages */
+	/* Soft offline could migrate non-LRU movable pages */
 	if ((flags & MF_SOFT_OFFLINE) && __PageMovable(page))
-		movable = true;
+		return true;
 
-	return movable || PageLRU(page) || is_free_buddy_page(page);
+	return PageLRU(page) || is_free_buddy_page(page);
 }
 
 static int __get_hwpoison_page(struct page *page, unsigned long flags)
Signature · 1 line
2.23.0
author maintainer
#2 lore raw

PATCH v2 2/2 mm/memory-failure.c: dissolve truncated hugetlb page

In reply to Miaohe Lin

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.

---
 mm/memory-failure.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
mm/memory-failure.c +4 -5
index 488aaca72340..1d64bfff339d 100644
@@ -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;
Signature · 1 line
2.23.0
#3 lore raw

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

Quoted 7 lines · Miaohe Lin

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.

Thank you for the update.