[PATCH v5 2/4] mm/memory-failure: set has_hwpoisoned flags on dissolved HugeTLB folio
From: Jiaqi Yan
Date: Sun May 31 2026 - 02:03:25 EST
When a free HWPoison HugeTLB folio is dissolved, it becomes
non-HugeTLB and is released to buddy allocator as a high-order
folio.
Set has_hwpoisoned flags on the high-order folio so that buddy
allocator can tell that it contains certain HWPoison page(s),
and can handle it specially with free_has_hwpoisoned().
Signed-off-by: Jiaqi Yan <jiaqiyan@xxxxxxxxxx>
---
include/linux/page-flags.h | 2 +-
mm/memory-failure.c | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index 7223f6f4e2b4..223ec3b2d62f 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -893,7 +893,7 @@ static inline int PageTransCompound(const struct page *page)
TESTPAGEFLAG_FALSE(TransCompound, transcompound)
#endif
-#if defined(CONFIG_MEMORY_FAILURE) && defined(CONFIG_TRANSPARENT_HUGEPAGE)
+#if defined(CONFIG_MEMORY_FAILURE) && (defined(CONFIG_TRANSPARENT_HUGEPAGE) || defined(CONFIG_HUGETLB_PAGE))
/*
* PageHasHWPoisoned indicates that at least one subpage is hwpoisoned in the
* compound page.
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 51508a55c405..95979b7995c1 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -1951,6 +1951,7 @@ void folio_clear_hugetlb_hwpoison(struct folio *folio)
if (folio_test_hugetlb_vmemmap_optimized(folio))
return;
folio_clear_hwpoison(folio);
+ folio_set_has_hwpoisoned(folio);
folio_free_raw_hwp(folio, true);
}
--
2.54.0.823.g6e5bcc1fc9-goog