[PATCH 6.6.y] mm/memory-failure: fix missing ->mf_stats count when hugetlb folio already poisoned

Qi Xi posted 1 patch 3 days, 11 hours ago
mm/memory-failure.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
[PATCH 6.6.y] mm/memory-failure: fix missing ->mf_stats count when hugetlb folio already poisoned
Posted by Qi Xi 3 days, 11 hours ago
[ Upstream commit a148a2040191b12b45b82cb29c281cb3036baf90 ]

When a new subpage is poisoned on a hugetlb folio that has already been
marked hwpoison (MF_HUGETLB_FOLIO_PRE_POISONED), hugetlb_update_hwpoison()
increments num_poisoned_pages directly, but the per-node ->mf_stats is
not updated because this path bypasses action_result().

The upstream commit fixed this by routing all counting through
action_result(), but the backport to 6.6 as commit 252bb328b36f applied
only the refactoring without the core counting fix. This patch adds the
missing update_per_node_mf_stats() call to fix the inconsistency.

Fixes: 252bb328b36f ("mm/memory-failure: fix missing ->mf_stats count in hugetlb poison")
Signed-off-by: Qi Xi <xiqi2@huawei.com>
---
 mm/memory-failure.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 86cdf36ee3bb..5f9203bf8ec1 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -1947,8 +1947,10 @@ static int hugetlb_update_hwpoison(struct folio *folio, struct page *page)
 		raw_hwp->page = page;
 		llist_add(&raw_hwp->node, head);
 		/* the first error event will be counted in action_result(). */
-		if (ret)
+		if (ret) {
 			num_poisoned_pages_inc(page_to_pfn(page));
+			update_per_node_mf_stats(page_to_pfn(page), MF_FAILED);
+		}
 	} else {
 		/*
 		 * Failed to save raw error info.  We no longer trace all
-- 
2.33.0
Re: [PATCH 6.6.y] mm/memory-failure: fix missing ->mf_stats count when hugetlb folio already poisoned
Posted by Greg Kroah-Hartman 3 days, 10 hours ago
On Tue, Jul 21, 2026 at 08:19:56PM +0800, Qi Xi wrote:
> [ Upstream commit a148a2040191b12b45b82cb29c281cb3036baf90 ]

That is not what this commit is :(
Re: [PATCH 6.6.y] mm/memory-failure: fix missing ->mf_stats count when hugetlb folio already poisoned
Posted by Qi Xi 1 day, 22 hours ago
You're right, I apologize for the misleading tag. This patch is a
follow-up fix for the defective backport 252bb328b36f — the bug does
not exist on mainline, so it's not a direct backport of any upstream
commit. I'll correct this in the next version.

Also, as in your earlier comment on the v1 thread about needing
maintainer acks — I'll ask for feedback from maintainers first before
sending the next revision.

Thanks,
Qi

On 21/07/2026 22:11, Greg Kroah-Hartman wrote:
> On Tue, Jul 21, 2026 at 08:19:56PM +0800, Qi Xi wrote:
>> [ Upstream commit a148a2040191b12b45b82cb29c281cb3036baf90 ]
> That is not what this commit is :(
>
>