Re: [PATCH v4 01/12] mm/rmap: convert page -> folio for hwpoison checks

From: David Hildenbrand (Arm)

Date: Wed Jun 10 2026 - 08:16:48 EST


On 6/10/26 09:02, Dev Jain wrote:
>
>
> On 09/06/26 7:14 pm, David Hildenbrand (Arm) wrote:
>> On 5/26/26 08:36, Dev Jain wrote:
>>> If any page of a folio is poisoned, try_to_unmap() is called with the
>>> intent to remove any mappings pointing to any part of the folio.
>>>
>>> Therefore, an hwpoison check on a single page does not make sense
>>> (although everything works out because the memory-failure path sets
>>> hwpoison on the head page too). Convert these checks to check whether
>>> the folio has at least one hwpoisoned page.
>>
>> I think the reasoning is different and should better be described:
>>
>> 1) For hugetlb, we will always get subpage == head page (single PTE -> first PFN).
>>
>> try_memory_failure_hugetlb()->try_memory_failure_hugetlb()->hugetlb_update_hwpoison()
>> will do the folio_test_set_hwpoison().
>>
>> folio_test_set_hwpoison() is the same as setting it on the head page.
>>
>> For hugetlb, subpage==headpage
>>
>> That's why PageHWPoison(subpage) used to work.
>>
>>
>> 2) try_to_unmap() cannot handle large folios (besides hugetlb folios).
>>
>> unmap_poisoned_folio() spells that out. That's why subpage==headpage right now.
>
> Should have mentioned: subpage != headpage for contpte mapped hugetlb folios
> on arm64.
No, hugetlb code always walks "logical" PTEs, not physical ones. So it will walk
each hugetlb folio only once, and always hit the head page.

That is, for cont-pte/pmd, it will always return the first PTE in the cont-pte
group.

See page_vma_mapped_walk()->hugetlb_walk machinery.

--
Cheers,

David