aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/page-flags.h
diff options
context:
space:
mode:
authorMatthew Wilcox (Oracle) <willy@infradead.org>2024-08-21 18:39:10 +0100
committerAndrew Morton <akpm@linux-foundation.org>2024-09-03 21:15:42 -0700
commite880034cf7182aa35962bd30dfc9fa60476d56a4 (patch)
tree55148be6aa56f0c4bf523dc7c6df26135454499c /include/linux/page-flags.h
parentprintf: remove %pGt support (diff)
downloadlinux-rng-e880034cf7182aa35962bd30dfc9fa60476d56a4.tar.xz
linux-rng-e880034cf7182aa35962bd30dfc9fa60476d56a4.zip
mm: introduce page_mapcount_is_type()
Resolve the awkward "and add one to this opaque constant" test into a self-documenting inline function. Link: https://lkml.kernel.org/r/20240821173914.2270383-3-willy@infradead.org Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Acked-by: David Hildenbrand <david@redhat.com> Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com> Cc: Kent Overstreet <kent.overstreet@linux.dev> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'include/linux/page-flags.h')
-rw-r--r--include/linux/page-flags.h12
1 files changed, 9 insertions, 3 deletions
diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index 2515ae85f191..0b5484fdbca1 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -956,12 +956,18 @@ enum pagetype {
#define folio_test_type(folio, flag) \
((READ_ONCE(folio->page.page_type) & (PAGE_TYPE_BASE | flag)) == PAGE_TYPE_BASE)
-static inline int page_type_has_type(unsigned int page_type)
+static inline bool page_type_has_type(int page_type)
{
- return (int)page_type < PAGE_MAPCOUNT_RESERVE;
+ return page_type < PAGE_MAPCOUNT_RESERVE;
}
-static inline int page_has_type(const struct page *page)
+/* This takes a mapcount which is one more than page->_mapcount */
+static inline bool page_mapcount_is_type(unsigned int mapcount)
+{
+ return page_type_has_type(mapcount - 1);
+}
+
+static inline bool page_has_type(const struct page *page)
{
return page_type_has_type(READ_ONCE(page->page_type));
}