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

"David Hildenbrand (Arm)" <[email protected]>
Newsgroups org.kernel.vger.stable,org.kernel.vger.linux-kernel,org.kvack.linux-mm
Message-ID <[email protected]>
> 
> 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.