Thread (96 messages) 96 messages, 6 authors, 2021-06-08

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

From: Christoph Hellwig <hch@infradead.org>
Date: 2021-05-27 08:31:25
Also in: linux-fsdevel, lkml

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?
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help