[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210511214735.1836149-17-willy@infradead.org>
Date: Tue, 11 May 2021 22:47:18 +0100
From: "Matthew Wilcox (Oracle)" <willy@...radead.org>
To: akpm@...ux-foundation.org
Cc: "Matthew Wilcox (Oracle)" <willy@...radead.org>,
linux-fsdevel@...r.kernel.org, linux-mm@...ck.org,
linux-kernel@...r.kernel.org, Christoph Hellwig <hch@....de>,
Jeff Layton <jlayton@...nel.org>
Subject: [PATCH v10 16/33] mm: Add folio_mapcount
This is the folio equivalent of page_mapcount().
Signed-off-by: Matthew Wilcox (Oracle) <willy@...radead.org>
Reviewed-by: Christoph Hellwig <hch@....de>
Acked-by: Jeff Layton <jlayton@...nel.org>
---
include/linux/mm.h | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index dca39daf3495..6e3dde81ecc9 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(folio_multi(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
Powered by blists - more mailing lists