Re: [PATCH v7 01/13] memory-failure: Fix hardware poison check in unpoison_memory() again

Matthew Wilcox <[email protected]> Fri, 31 Jul 2026 21:00:13 +0100
Newsgroups org.kernel.vger.linux-fsdevel,org.kernel.vger.stable,org.kvack.linux-mm
Message-ID <[email protected]>
On Thu, Jul 30, 2026 at 04:45:19PM +0800, Miaohe Lin wrote:
> On 2026/7/29 9:43, Matthew Wilcox wrote:
> > The careful reader will observe that injecting two memory failures
> > into the same hugetlb causes ... problems.  That's true before and after
> 
> Could you elaborate on what problems this might cause? IIUC, second memory
> failure on the same hugetlb folio will make try_memory_failure_hugetlb() return
> -EHWPOISON without holding another refcnt. Raw error pages will be added to
> raw_hwp_page list. Then in unpoison_memory(), raw_hwp_page list will be cleaned
> and extra refcnt held by memory_failure will be released and PageHWPoison will be
> cleared. So it looks work to me. Or am I miss something?

Thanks for the explanation of what happens.  What's confusing to me is
that we can poison pfn A and pfn A xor 1, then unpoison pfn A and that
causes pfn A^1 to be unpoisoned too (if they're in a hugetlb folio).
That's an unexpected difference to me; I'd expect to be able to set/clear
their poison individually.

But it has been this way for many years, so I presume people are either
used to it, or don't notice.

> Reviewed-by: Miaohe Lin <[email protected]>

Thanks, added.