Re: [PATCH v3] mm/memory-failure: set PG_hwpoison of a non-hugetlb page under hugetlb_lock

From: Miaohe Lin

Date: Mon Nov 23 2026 - 02:27:05 EST


On 2026/11/23 14:19, Mani Tofigh wrote:
>
>
> On 11/17/26 2:01 AM, Miaohe Lin wrote:
>> In both cases, will the hwpoison flag be lost? If so, would TestClearPageHWPoison work?
>
> Only if P's struct page is past the first vmemmap page, since HVO frees

If P's struct page is past the first vmemmap page, the hwpoison flag is lost. In this case,
do we need to do something? Now that hwpoison flag is already lost, I don't think so. And
TestClearPageHWPoison won't do anything in this case. Or do you mean TestClearPageHWPoison
will always write even if hwpoison flag is not set? If so, can test + clear do the work?

> that one. In the first page it's copied, so the flag stays. And

In the first page, the hwpoison flag stays. So TestClearPageHWPoison can do the right thing here?

> TestClearPageHWPoison() is still an atomic write, so it'd fault on the> read-only tail (e.g., 6.6) the same way.
>
>
>> If the page becomes hugetlb, should we skip the retry path? try_memory_failure_hugetlb
>> can't handle this case?
>>
>
>
> It can, the only problem is the stale flag from the first round. With it, hugetlb_update_hwpoison() thinks the folio is already poisoned if
> P is the head, and unpoison_memory() drops the folio ref twice if
> P is a tail.

I think we can correctly clear the stale flag from the first round.

Am I miss something?
Thanks.
.