Skip to content

Commit

Permalink
mm: convert page_mapcount() to use folio_entire_mapcount()
Browse files Browse the repository at this point in the history
Remove a use of head_compound_mapcount().

Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Matthew Wilcox (Oracle) <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
  • Loading branch information
Matthew Wilcox (Oracle) authored and akpm00 committed Feb 3, 2023
1 parent 46f2722 commit c97eeb8
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions include/linux/mm.h
Original file line number Diff line number Diff line change
Expand Up @@ -853,22 +853,26 @@ static inline void page_mapcount_reset(struct page *page)
atomic_set(&(page)->_mapcount, -1);
}

/*
* Mapcount of 0-order page; when compound sub-page, includes
* compound_mapcount of compound_head of page.
/**
* page_mapcount() - Number of times this precise page is mapped.
* @page: The page.
*
* The number of times this page is mapped. If this page is part of
* a large folio, it includes the number of times this page is mapped
* as part of that folio.
*
* Result is undefined for pages which cannot be mapped into userspace.
* The result is undefined for pages which cannot be mapped into userspace.
* For example SLAB or special types of pages. See function page_has_type().
* They use this place in struct page differently.
* They use this field in struct page differently.
*/
static inline int page_mapcount(struct page *page)
{
int mapcount = atomic_read(&page->_mapcount) + 1;

if (likely(!PageCompound(page)))
return mapcount;
page = compound_head(page);
return head_compound_mapcount(page) + mapcount;
if (unlikely(PageCompound(page)))
mapcount += folio_entire_mapcount(page_folio(page));

return mapcount;
}

int folio_total_mapcount(struct folio *folio);
Expand Down

0 comments on commit c97eeb8

Please sign in to comment.