mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/2] mm/hugetlb: clear the hugetlb flag before leaking a hwpoisoned folio
@ 2026-11-03 21:00 Mani Tofigh via B4 Relay
  2026-11-03 21:00 ` [PATCH v2 1/2] mm/memory-failure: don't unpoison a leaked raw_hwp_unreliable folio Mani Tofigh via B4 Relay
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Mani Tofigh via B4 Relay @ 2026-11-03 21:00 UTC (permalink / raw)
  To: Muchun Song, Oscar Salvador, David Hildenbrand, Miaohe Lin,
	Andrew Morton
  Cc: Naoya Horiguchi, Matthew Wilcox, Jane Chu, Zi Yan, Kaitao Cheng,
	Mike Rapoport, Mike Kravetz, Yu Zhao, linux-mm, linux-kernel,
	tz2294, stable, Mani Tofigh

If memory_failure() can't save the raw error page of a hugetlb folio,
the folio is marked raw_hwp_unreliable and leaked once it's freed.  With
hugetlb_free_vmemmap=on it's leaked while it's still a hugetlb folio,
and dissolving it then loops forever, e.g., when offlining its memory
block.  Patch 2 leaks it only after the hugetlb flag is cleared, as
without vmemmap optimization.

Miaohe pointed out that unpoison_memory() then doesn't see a hugetlb
folio anymore and unpoisons it.  That already happens without vmemmap
optimization, so patch 1 fixes it on its own and goes first.

Patch 2 lets a raw_hwp_unreliable folio reach the add_hugetlb_folio()
rollback when restoring its vmemmap fails, as
dissolve_free_hugetlb_folio() already does.  It relies on Kaitao's
"mm/hugetlb: preserve persistent flags when returning folios to the
pool" [1] (in mm-new) to keep the flag there.

Reproducer: https://github.com/manitofigh/files/blob/main/linux-repros/hugeoffline.c

[1] https://lore.kernel.org/all/20261102024910.31486-3-kaitao.cheng@linux.dev/

Changes in v2:
- New patch 1 so unpoison_memory() refuses the leaked folio (Miaohe).
- Patch 2: same code, added Fixes: bd225530a4c7 and fixed the commit
  message (offlining still retries until a signal).
- Rebased on mm-new.
- Link to v1: https://lore.kernel.org/all/20261028-hugetlb-hwpoison-leak-v1-1-77ce56002523@columbia.edu/

---
Mani Tofigh (2):
      mm/memory-failure: don't unpoison a leaked raw_hwp_unreliable folio
      mm/hugetlb: clear the hugetlb flag before leaking a hwpoisoned folio

 mm/hugetlb.c        | 15 ++++++++-------
 mm/memory-failure.c |  9 +++++++++
 2 files changed, 17 insertions(+), 7 deletions(-)
---
base-commit: 74d73ffcffe03804f97e9fb82301dadf75671282
change-id: 20261028-hugetlb-hwpoison-leak-b8d344361413

Best regards,
--  
Mani Tofigh <mt4022@columbia.edu>



^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2 1/2] mm/memory-failure: don't unpoison a leaked raw_hwp_unreliable folio
  2026-11-03 21:00 [PATCH v2 0/2] mm/hugetlb: clear the hugetlb flag before leaking a hwpoisoned folio Mani Tofigh via B4 Relay
@ 2026-11-03 21:00 ` Mani Tofigh via B4 Relay
  2026-11-19  6:39   ` Miaohe Lin
  2026-11-03 21:00 ` [PATCH v2 2/2] mm/hugetlb: clear the hugetlb flag before leaking a hwpoisoned folio Mani Tofigh via B4 Relay
  2026-11-19  7:06 ` [PATCH v2 0/2] " Andrew Morton
  2 siblings, 1 reply; 8+ messages in thread
From: Mani Tofigh via B4 Relay @ 2026-11-03 21:00 UTC (permalink / raw)
  To: Muchun Song, Oscar Salvador, David Hildenbrand, Miaohe Lin,
	Andrew Morton
  Cc: Naoya Horiguchi, Matthew Wilcox, Jane Chu, Zi Yan, Kaitao Cheng,
	Mike Rapoport, Mike Kravetz, Yu Zhao, linux-mm, linux-kernel,
	tz2294, stable, Mani Tofigh

From: Mani Tofigh <mt4022@columbia.edu>

If memory_failure() can't save the raw error page of a hugetlb folio,
it marks the folio raw_hwp_unreliable and unpoison_memory() refuses to
unpoison it, since we don't know which subpages are poisoned.  Once the
folio is freed, __update_and_free_hugetlb_folio() leaks it on purpose.
If its hugetlb flag is cleared by then, e.g., without vmemmap
optimization, unpoison_memory() doesn't see a hugetlb folio anymore.
It treats the leaked folio as a normal page and clears PG_hwpoison on
its head, while the poisoned subpages are still unknown.

The leaked folio is still a large folio and raw_hwp_unreliable stays set
in folio->private.  We now check it on any large folio before taking the
page, so unpoison_memory() refuses the folio whether it's still hugetlb
or not.  With the fix, it returns -EBUSY for the leaked folio as it did
before the folio was freed.

Fixes: ac5fcde0a96a ("mm, hwpoison: make unpoison aware of raw error info in hwpoisoned hugepage")
Reported-by: Miaohe Lin <linmiaohe@huawei.com>
Closes: https://lore.kernel.org/all/ae6058ae-3703-a1d5-d82f-4102b46f227b@huawei.com/
Cc: stable@vger.kernel.org
Signed-off-by: Mani Tofigh <mt4022@columbia.edu>
---
 mm/memory-failure.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index b215312f261b..496eacbefdf2 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -2809,6 +2809,15 @@ int unpoison_memory(unsigned long pfn)
 		goto unlock_mutex;
 	}
 
+	/*
+	 * A hugetlb folio without reliable raw error info is leaked once it
+	 * is freed, and its hugetlb flag may be cleared by then.  Check the
+	 * flag in folio->private, which stays set on the leaked folio.
+	 */
+	if (folio_test_large(folio) &&
+	    folio_test_hugetlb_raw_hwp_unreliable(folio))
+		goto unlock_mutex;
+
 	ghp = get_hwpoison_page(p, MF_UNPOISON);
 	if (!ghp) {
 		if (folio_test_hugetlb(folio)) {

-- 
2.53.0



^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2 2/2] mm/hugetlb: clear the hugetlb flag before leaking a hwpoisoned folio
  2026-11-03 21:00 [PATCH v2 0/2] mm/hugetlb: clear the hugetlb flag before leaking a hwpoisoned folio Mani Tofigh via B4 Relay
  2026-11-03 21:00 ` [PATCH v2 1/2] mm/memory-failure: don't unpoison a leaked raw_hwp_unreliable folio Mani Tofigh via B4 Relay
@ 2026-11-03 21:00 ` Mani Tofigh via B4 Relay
  2026-11-19  6:40   ` Miaohe Lin
  2026-11-19  7:06 ` [PATCH v2 0/2] " Andrew Morton
  2 siblings, 1 reply; 8+ messages in thread
From: Mani Tofigh via B4 Relay @ 2026-11-03 21:00 UTC (permalink / raw)
  To: Muchun Song, Oscar Salvador, David Hildenbrand, Miaohe Lin,
	Andrew Morton
  Cc: Naoya Horiguchi, Matthew Wilcox, Jane Chu, Zi Yan, Kaitao Cheng,
	Mike Rapoport, Mike Kravetz, Yu Zhao, linux-mm, linux-kernel,
	tz2294, stable, Mani Tofigh

From: Mani Tofigh <mt4022@columbia.edu>

If hugetlb_update_hwpoison() fails to allocate a raw_hwp_page, the folio
is marked raw_hwp_unreliable and __update_and_free_hugetlb_folio() leaks
it intentionally.  With hugetlb_free_vmemmap=on, it's leaked before the
hugetlb flag is cleared, since commit 32c877191e02 ("hugetlb: do not
clear hugetlb dtor until allocating vmemmap") doesn't remove the flag
until the vmemmap is restored.  The leaked folio is then a hugetlb folio
with refcount 0 and on no list (the same state as a hugetlb folio that
is being freed), but nothing is freeing it, and
dissolve_free_hugetlb_folio() keeps retrying on it.  Offlining its
memory block then never completes, even on SIGKILL, and other tasks
block on the memory hotplug lock:

  [    3.271255] Memory failure: 0x20007: recovery action for free huge page: Failed
  [   41.729695] INFO: task hugeoffline:77 blocked for more than 20 seconds.
  ...
  [   41.733014]  get_online_mems+0xc1/0xd0
  [   41.733026]  soft_offline_page+0xfd/0x9b0

alloc_and_dissolve_hugetlb_folio() loops on it the same way.  The
refcount is 0 since commit bd225530a4c7 ("mm/hugetlb_vmemmap: fix race
with speculative PFN walkers").  Before that these paths failed with
-EBUSY.

Check raw_hwp_unreliable after the hugetlb flag is cleared so that the
folio is leaked as a non-hugetlb folio, as without vmemmap
optimization.  unpoison_memory() keeps refusing to unpoison it.  With
the fix, offlining retries as it does for any page it can't isolate,
and stops on a signal.

Fixes: 32c877191e02 ("hugetlb: do not clear hugetlb dtor until allocating vmemmap")
Fixes: bd225530a4c7 ("mm/hugetlb_vmemmap: fix race with speculative PFN walkers")
Cc: stable@vger.kernel.org
Signed-off-by: Mani Tofigh <mt4022@columbia.edu>
---
This relies on Kaitao's "mm/hugetlb: preserve persistent flags when
returning folios to the pool" [1] (673b553e2bba in mm-new).  The check
now comes after hugetlb_vmemmap_restore_folio(), so on a restore failure
add_hugetlb_folio() must keep raw_hwp_unreliable.  It would be good to
take [1] to stable along with this one.

This changes the same lines as patch 07/15 of Matthew's "Use
generic_file_read_iter() in hugetlbfs" series [2].  On top of that
series, the check goes right after the folio_clear_hugetlb() call.

[1] https://lore.kernel.org/all/20261102024910.31486-3-kaitao.cheng@linux.dev/
[2] https://lore.kernel.org/all/20260805210557.1118966-8-willy@infradead.org/

Reproducer: https://github.com/manitofigh/files/blob/main/linux-repros/hugeoffline.c
---
 mm/hugetlb.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 779b1de33c78..cdeb8923083f 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1480,13 +1480,6 @@ static void __update_and_free_hugetlb_folio(struct hstate *h,
 		return;
 	}
 
-	/*
-	 * If we don't know which subpages are hwpoisoned, we can't free
-	 * the hugepage, so it's leaked intentionally.
-	 */
-	if (folio_test_hugetlb_raw_hwp_unreliable(folio))
-		return;
-
 	/*
 	 * If folio is not vmemmap optimized (!clear_flag), then the folio
 	 * is no longer identified as a hugetlb page.  hugetlb_vmemmap_restore_folio
@@ -1514,6 +1507,14 @@ static void __update_and_free_hugetlb_folio(struct hstate *h,
 		spin_unlock_irq(&hugetlb_lock);
 	}
 
+	/*
+	 * If we don't know which subpages are hwpoisoned, we can't free
+	 * the hugepage, so it's leaked intentionally, but only once it is
+	 * no longer a hugetlb folio.
+	 */
+	if (folio_test_hugetlb_raw_hwp_unreliable(folio))
+		return;
+
 	/*
 	 * Move PageHWPoison flag from head page to the raw error pages,
 	 * which makes any healthy subpages reusable.

-- 
2.53.0



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 1/2] mm/memory-failure: don't unpoison a leaked raw_hwp_unreliable folio
  2026-11-03 21:00 ` [PATCH v2 1/2] mm/memory-failure: don't unpoison a leaked raw_hwp_unreliable folio Mani Tofigh via B4 Relay
@ 2026-11-19  6:39   ` Miaohe Lin
  2026-11-19  7:11     ` Andrew Morton
  0 siblings, 1 reply; 8+ messages in thread
From: Miaohe Lin @ 2026-11-19  6:39 UTC (permalink / raw)
  To: mt4022
  Cc: Naoya Horiguchi, Matthew Wilcox, Jane Chu, Zi Yan, Kaitao Cheng,
	Mike Rapoport, Mike Kravetz, Yu Zhao, linux-mm, linux-kernel,
	tz2294, stable, Muchun Song, Oscar Salvador, David Hildenbrand,
	Andrew Morton

On 2026/11/4 5:00, Mani Tofigh via B4 Relay wrote:
> From: Mani Tofigh <mt4022@columbia.edu>
> 
> If memory_failure() can't save the raw error page of a hugetlb folio,
> it marks the folio raw_hwp_unreliable and unpoison_memory() refuses to
> unpoison it, since we don't know which subpages are poisoned.  Once the
> folio is freed, __update_and_free_hugetlb_folio() leaks it on purpose.
> If its hugetlb flag is cleared by then, e.g., without vmemmap
> optimization, unpoison_memory() doesn't see a hugetlb folio anymore.
> It treats the leaked folio as a normal page and clears PG_hwpoison on
> its head, while the poisoned subpages are still unknown.
> 
> The leaked folio is still a large folio and raw_hwp_unreliable stays set
> in folio->private.  We now check it on any large folio before taking the
> page, so unpoison_memory() refuses the folio whether it's still hugetlb
> or not.  With the fix, it returns -EBUSY for the leaked folio as it did
> before the folio was freed.
> 
> Fixes: ac5fcde0a96a ("mm, hwpoison: make unpoison aware of raw error info in hwpoisoned hugepage")
> Reported-by: Miaohe Lin <linmiaohe@huawei.com>
> Closes: https://lore.kernel.org/all/ae6058ae-3703-a1d5-d82f-4102b46f227b@huawei.com/
> Cc: stable@vger.kernel.org
> Signed-off-by: Mani Tofigh <mt4022@columbia.edu>
> ---
>  mm/memory-failure.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/mm/memory-failure.c b/mm/memory-failure.c
> index b215312f261b..496eacbefdf2 100644
> --- a/mm/memory-failure.c
> +++ b/mm/memory-failure.c
> @@ -2809,6 +2809,15 @@ int unpoison_memory(unsigned long pfn)
>  		goto unlock_mutex;
>  	}
>  
> +	/*
> +	 * A hugetlb folio without reliable raw error info is leaked once it
> +	 * is freed, and its hugetlb flag may be cleared by then.  Check the
> +	 * flag in folio->private, which stays set on the leaked folio.
> +	 */
> +	if (folio_test_large(folio) &&
> +	    folio_test_hugetlb_raw_hwp_unreliable(folio))

It might be better to add a unpoison_pr_info here?

> +		goto unlock_mutex;

Anyway, this patch LGTM:

Acked-by: Miaohe Lin <linmiaohe@huawei.com>

Thanks.
.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 2/2] mm/hugetlb: clear the hugetlb flag before leaking a hwpoisoned folio
  2026-11-03 21:00 ` [PATCH v2 2/2] mm/hugetlb: clear the hugetlb flag before leaking a hwpoisoned folio Mani Tofigh via B4 Relay
@ 2026-11-19  6:40   ` Miaohe Lin
  0 siblings, 0 replies; 8+ messages in thread
From: Miaohe Lin @ 2026-11-19  6:40 UTC (permalink / raw)
  To: mt4022
  Cc: Naoya Horiguchi, Matthew Wilcox, Jane Chu, Zi Yan, Kaitao Cheng,
	Mike Rapoport, Mike Kravetz, Yu Zhao, linux-mm, linux-kernel,
	tz2294, stable, Muchun Song, Oscar Salvador, David Hildenbrand,
	Andrew Morton

On 2026/11/4 5:00, Mani Tofigh via B4 Relay wrote:
> From: Mani Tofigh <mt4022@columbia.edu>
> 
> If hugetlb_update_hwpoison() fails to allocate a raw_hwp_page, the folio
> is marked raw_hwp_unreliable and __update_and_free_hugetlb_folio() leaks
> it intentionally.  With hugetlb_free_vmemmap=on, it's leaked before the
> hugetlb flag is cleared, since commit 32c877191e02 ("hugetlb: do not
> clear hugetlb dtor until allocating vmemmap") doesn't remove the flag
> until the vmemmap is restored.  The leaked folio is then a hugetlb folio
> with refcount 0 and on no list (the same state as a hugetlb folio that
> is being freed), but nothing is freeing it, and
> dissolve_free_hugetlb_folio() keeps retrying on it.  Offlining its
> memory block then never completes, even on SIGKILL, and other tasks
> block on the memory hotplug lock:
> 
>   [    3.271255] Memory failure: 0x20007: recovery action for free huge page: Failed
>   [   41.729695] INFO: task hugeoffline:77 blocked for more than 20 seconds.
>   ...
>   [   41.733014]  get_online_mems+0xc1/0xd0
>   [   41.733026]  soft_offline_page+0xfd/0x9b0
> 
> alloc_and_dissolve_hugetlb_folio() loops on it the same way.  The
> refcount is 0 since commit bd225530a4c7 ("mm/hugetlb_vmemmap: fix race
> with speculative PFN walkers").  Before that these paths failed with
> -EBUSY.
> 
> Check raw_hwp_unreliable after the hugetlb flag is cleared so that the
> folio is leaked as a non-hugetlb folio, as without vmemmap
> optimization.  unpoison_memory() keeps refusing to unpoison it.  With
> the fix, offlining retries as it does for any page it can't isolate,
> and stops on a signal.
> 
> Fixes: 32c877191e02 ("hugetlb: do not clear hugetlb dtor until allocating vmemmap")
> Fixes: bd225530a4c7 ("mm/hugetlb_vmemmap: fix race with speculative PFN walkers")
> Cc: stable@vger.kernel.org
> Signed-off-by: Mani Tofigh <mt4022@columbia.edu>

Reviewed-by: Miaohe Lin <linmiaohe@huawei.com>

Thanks.
.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 0/2] mm/hugetlb: clear the hugetlb flag before leaking a hwpoisoned folio
  2026-11-03 21:00 [PATCH v2 0/2] mm/hugetlb: clear the hugetlb flag before leaking a hwpoisoned folio Mani Tofigh via B4 Relay
  2026-11-03 21:00 ` [PATCH v2 1/2] mm/memory-failure: don't unpoison a leaked raw_hwp_unreliable folio Mani Tofigh via B4 Relay
  2026-11-03 21:00 ` [PATCH v2 2/2] mm/hugetlb: clear the hugetlb flag before leaking a hwpoisoned folio Mani Tofigh via B4 Relay
@ 2026-11-19  7:06 ` Andrew Morton
  2 siblings, 0 replies; 8+ messages in thread
From: Andrew Morton @ 2026-11-19  7:06 UTC (permalink / raw)
  To: Mani Tofigh
  Cc: Muchun Song, Oscar Salvador, David Hildenbrand, Miaohe Lin,
	Naoya Horiguchi, Matthew Wilcox, Jane Chu, Zi Yan, Kaitao Cheng,
	Mike Rapoport, Mike Kravetz, Yu Zhao, linux-mm, linux-kernel,
	tz2294, stable

On Tue, 03 Nov 2026 16:00:48 -0500 Mani Tofigh <mt4022@columbia.edu> wrote:

> If memory_failure() can't save the raw error page of a hugetlb folio,
> the folio is marked raw_hwp_unreliable and leaked once it's freed.  With
> hugetlb_free_vmemmap=on it's leaked while it's still a hugetlb folio,
> and dissolving it then loops forever, e.g., when offlining its memory
> block.  Patch 2 leaks it only after the hugetlb flag is cleared, as
> without vmemmap optimization.
> 
> Miaohe pointed out that unpoison_memory() then doesn't see a hugetlb
> folio anymore and unpoisons it.  That already happens without vmemmap
> optimization, so patch 1 fixes it on its own and goes first.
> 
> Patch 2 lets a raw_hwp_unreliable folio reach the add_hugetlb_folio()
> rollback when restoring its vmemmap fails, as
> dissolve_free_hugetlb_folio() already does.  It relies on Kaitao's
> "mm/hugetlb: preserve persistent flags when returning folios to the
> pool" [1] (in mm-new) to keep the flag there.

Problem.  [1] doesn't have cc:stable whereas your patches do.  So we're
sending -stable people something which won't work.

I don't know if there's a way of expressing such a dependency for the
-stable machinery but fortunately [1] is still in development mode (ie,
in mm-unstable), so I can add a cc:stable to that along with an
explanatory note.

And I agree that these two patches are -stable material, especially
[2/2].  Having an offlining attempt lock up until reboot is not our
preferred user experience ;)


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 1/2] mm/memory-failure: don't unpoison a leaked raw_hwp_unreliable folio
  2026-11-19  6:39   ` Miaohe Lin
@ 2026-11-19  7:11     ` Andrew Morton
  2026-11-19  7:30       ` Miaohe Lin
  0 siblings, 1 reply; 8+ messages in thread
From: Andrew Morton @ 2026-11-19  7:11 UTC (permalink / raw)
  To: Miaohe Lin
  Cc: mt4022, Naoya Horiguchi, Matthew Wilcox, Jane Chu, Zi Yan,
	Kaitao Cheng, Mike Rapoport, Mike Kravetz, Yu Zhao, linux-mm,
	linux-kernel, tz2294, stable, Muchun Song, Oscar Salvador,
	David Hildenbrand

On Thu, 19 Nov 2026 14:39:24 +0800 Miaohe Lin <linmiaohe@huawei.com> wrote:

> > +	/*
> > +	 * A hugetlb folio without reliable raw error info is leaked once it
> > +	 * is freed, and its hugetlb flag may be cleared by then.  Check the
> > +	 * flag in folio->private, which stays set on the leaked folio.
> > +	 */
> > +	if (folio_test_large(folio) &&
> > +	    folio_test_hugetlb_raw_hwp_unreliable(folio))
> 
> It might be better to add a unpoison_pr_info here?

How does this look?

--- a/mm/memory-failure.c~mm-memory-failure-dont-unpoison-a-leaked-raw_hwp_unreliable-folio-fix
+++ a/mm/memory-failure.c
@@ -2818,8 +2818,12 @@ int unpoison_memory(unsigned long pfn)
 	 * flag in folio->private, which stays set on the leaked folio.
 	 */
 	if (folio_test_large(folio) &&
-	    folio_test_hugetlb_raw_hwp_unreliable(folio))
+	    folio_test_hugetlb_raw_hwp_unreliable(folio)) {
+		unpoison_pr_info("%#lx: cannot unpoison, poisoned subpages are unknown\n",
+				 pfn, &unpoison_rs);
+					
 		goto unlock_mutex;
+	}
 
 	ghp = get_hwpoison_page(p, MF_UNPOISON);
 	if (!ghp) {
_


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 1/2] mm/memory-failure: don't unpoison a leaked raw_hwp_unreliable folio
  2026-11-19  7:11     ` Andrew Morton
@ 2026-11-19  7:30       ` Miaohe Lin
  0 siblings, 0 replies; 8+ messages in thread
From: Miaohe Lin @ 2026-11-19  7:30 UTC (permalink / raw)
  To: Andrew Morton
  Cc: mt4022, Naoya Horiguchi, Matthew Wilcox, Jane Chu, Zi Yan,
	Kaitao Cheng, Mike Rapoport, Mike Kravetz, Yu Zhao, linux-mm,
	linux-kernel, tz2294, stable, Muchun Song, Oscar Salvador,
	David Hildenbrand

On 2026/11/19 15:11, Andrew Morton wrote:
> On Thu, 19 Nov 2026 14:39:24 +0800 Miaohe Lin <linmiaohe@huawei.com> wrote:
> 
>>> +	/*
>>> +	 * A hugetlb folio without reliable raw error info is leaked once it
>>> +	 * is freed, and its hugetlb flag may be cleared by then.  Check the
>>> +	 * flag in folio->private, which stays set on the leaked folio.
>>> +	 */
>>> +	if (folio_test_large(folio) &&
>>> +	    folio_test_hugetlb_raw_hwp_unreliable(folio))
>>
>> It might be better to add a unpoison_pr_info here?
> 
> How does this look?
> 
> --- a/mm/memory-failure.c~mm-memory-failure-dont-unpoison-a-leaked-raw_hwp_unreliable-folio-fix
> +++ a/mm/memory-failure.c
> @@ -2818,8 +2818,12 @@ int unpoison_memory(unsigned long pfn)
>  	 * flag in folio->private, which stays set on the leaked folio.
>  	 */
>  	if (folio_test_large(folio) &&
> -	    folio_test_hugetlb_raw_hwp_unreliable(folio))
> +	    folio_test_hugetlb_raw_hwp_unreliable(folio)) {
> +		unpoison_pr_info("%#lx: cannot unpoison, poisoned subpages are unknown\n",
> +				 pfn, &unpoison_rs);
> +					
>  		goto unlock_mutex;
> +	}
>  

Looks good to me. Thanks Andrew.

>  	ghp = get_hwpoison_page(p, MF_UNPOISON);
>  	if (!ghp) {
> _
> 
> 
> .
> 


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-11-19  7:30 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-03 21:00 [PATCH v2 0/2] mm/hugetlb: clear the hugetlb flag before leaking a hwpoisoned folio Mani Tofigh via B4 Relay
2026-11-03 21:00 ` [PATCH v2 1/2] mm/memory-failure: don't unpoison a leaked raw_hwp_unreliable folio Mani Tofigh via B4 Relay
2026-11-19  6:39   ` Miaohe Lin
2026-11-19  7:11     ` Andrew Morton
2026-11-19  7:30       ` Miaohe Lin
2026-11-03 21:00 ` [PATCH v2 2/2] mm/hugetlb: clear the hugetlb flag before leaking a hwpoisoned folio Mani Tofigh via B4 Relay
2026-11-19  6:40   ` Miaohe Lin
2026-11-19  7:06 ` [PATCH v2 0/2] " Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®