Re: [PATCH] mm: avoid poison consumption when splitting THP
From: David Hildenbrand
Date: Thu Sep 11 2025 - 04:12:54 EST
On 11.09.25 04:14, Andrew Zaborowski wrote:
Handling a memory failure pointing inside a huge page requires splitting
the page. The splitting logic uses a mechanism, implemented in
migrate.c:try_to_map_unused_to_zeropage(), that inspects contents of
individual pages to find zero-filled pages. The read access to the
contents may cause a new, synchronous exception like an x86 Machine
Check, delivered before the initial memory_failure() finishes, ending
in a crash.
Luckily memory_failure() already sets the has_hwpoisoned flag on the
folio right before try_to_split_thp_page(). Don't enable the shared
zeropage mechanism (RMP_USE_SHARED_ZEROPAGE flag) down in
__split_unmapped_folio() when the original folio has has_hwpoisoned.
Note: we're disabling a potentially useful feature, some of the
individual pages that aren't poisoned might be zero-filled. One
argument for not trying to add a mechanism to maybe re-scan them later,
apart from code cost, is that the owning process is likely being
killed and the memory released.
Signed-off-by: Andrew Zaborowski <balrogg+code@xxxxxxxxx>
---
I would suggest just checking whether the page (PageHWPoison()) is poisoned before doing the check for zero. If set, just treat it as non-zero.
No need to stop the split.
You'll have to do that in two locations.
No need to mess with RMP_USE_SHARED_ZEROPAGE
--
Cheers
David / dhildenb