Re: [PATCH v10 33/33] mm: Add folio_mapped

From: Christoph Hellwig
Date: Thu May 27 2021 - 04:31:25 EST


On Tue, May 11, 2021 at 10:47:35PM +0100, Matthew Wilcox (Oracle) wrote:
> This function is the equivalent of page_mapped(). It is slightly
> shorter as we do not need to handle the PageTail() case. Reimplement
> page_mapped() as a wrapper around folio_mapped().

No byte savings numbers as for the other patches?

The patch itself looks good, although I'd go for a slightly easier
readable structure:

bool folio_mapped(struct folio *folio)
{
if (folio_single(folio))
return atomic_read(&folio->_mapcount) >= 0;

if (atomic_read(compound_mapcount_ptr(&folio->page)) >= 0)
return true;

if (!folio_hugetlb(folio)) {
unsigned long i;

for (i = 0; i < folio_nr_pages(folio); i++)
if (atomic_read(&folio_page(folio, i)->_mapcount) >= 0)
return true;
}
return false;
}

Shouldn't we also have a folio version of compound_mapcount_ptr?