[PATCH v7 15/28] mm: Add folio_mapcount
Matthew Wilcox (Oracle)
willy at infradead.org
Fri Apr 9 19:50:52 BST 2021
This is the folio equivalent of page_mapcount().
Signed-off-by: Matthew Wilcox (Oracle) <willy at infradead.org>
Reviewed-by: Christoph Hellwig <hch at lst.de>
Acked-by: Jeff Layton <jlayton at kernel.org>
---
include/linux/mm.h | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 143b354c3f4a..7bd2ce197e2f 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -883,6 +883,22 @@ static inline int page_mapcount(struct page *page)
return atomic_read(&page->_mapcount) + 1;
}
+/**
+ * folio_mapcount - The number of mappings of this folio.
+ * @folio: The folio.
+ *
+ * The result includes the number of times any of the pages in the
+ * folio are mapped to userspace.
+ *
+ * Return: The number of page table entries which refer to this folio.
+ */
+static inline int folio_mapcount(struct folio *folio)
+{
+ if (unlikely(FolioMulti(folio)))
+ return __page_mapcount(&folio->page);
+ return atomic_read(&folio->_mapcount) + 1;
+}
+
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
int total_mapcount(struct page *page);
int page_trans_huge_mapcount(struct page *page, int *total_mapcount);
--
2.30.2
More information about the linux-afs
mailing list