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

From: Mani Tofigh

Date: Mon Nov 23 2026 - 01:19:51 EST




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
that one. In the first page it's copied, so the flag stays. And
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.

Now that Muchun's vmemmap_remap_rwsem is in mm-new though, I think we can just clear the flag under it (unless HVO already moved P's struct page to the shared tail, where it's gone anyway) and always retry. That'd also let us drop the hugetlb.c part. WDYT?

Mani