]> www.infradead.org Git - users/willy/pagecache.git/commitdiff
mm: Convert page_mapcount() to use folio_entire_mapcount()
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Fri, 30 Dec 2022 20:30:44 +0000 (15:30 -0500)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Tue, 3 Jan 2023 04:00:55 +0000 (23:00 -0500)
Remove a use of head_compound_mapcount().

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
include/linux/mm.h

index 0079f779da47984ea0ba94f1f52a596e9ce9fbb9..cc6e94647ed8baab13717b7f5be95dcaa4922338 100644 (file)
@@ -848,22 +848,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);