Re: [PATCH v2] mm/madvise: avoid skipping pages after splitting large folios

From: David Hildenbrand (Arm)

Date: Thu Aug 06 2026 - 07:35:51 EST


>
> Let's at least split out the folio check into a helper to make things
> clearer:
>
> static bool poison_splits_folio(const struct folio *folio)
> {
> /* Hugetlb is, as always, a world unto itself. */
> if (folio_test_hugetlb(folio))
> return false;
> /* Soft-offline errors out, hwpoison traverse DAX intact. */
> if (folio_is_zone_device(folio))
> return false;
> return true;
> }
>
> Then for your patch:
>
> - size = PAGE_SIZE;
> - if (folio_test_hugetlb(folio) || folio_is_zone_device(folio))
> - size = folio_size(folio);
> + size = poison_splits_folio(folio) ? PAGE_SIZE : folio_size(folio);
>
> I tried writing something that was neater and nicer but AI kept pointing
> out how it was totally broken and I really really hate this code (not your
> fault :).

No, I don't think any such special casing on folios is the right way to handle it.

--
Cheers,

David