[PATCH 1/7] mm/hugetlb: add folio support to hugetlb specific flag macros

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Allows the macros which test, set, and clear hugetlb specific page
flags to take a hugetlb folio as an input. The marcros are generated as
folio_{test, set, clear}_hugetlb_{restore_reserve, migratable,
temporary, freed, vmemmap_optimized, raw_hwp_unreliable}.

Signed-off-by: Sidhartha Kumar <sidhartha.kumar@xxxxxxxxxx>
---
 include/linux/hugetlb.h | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index acace1a25226..ac4e98edd5b0 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -583,26 +583,47 @@ enum hugetlb_page_flags {
  */
 #ifdef CONFIG_HUGETLB_PAGE
 #define TESTHPAGEFLAG(uname, flname)				\
+static __always_inline								\
+int folio_test_hugetlb_##flname(struct folio *folio)		\
+	{	void **private = &folio->private;		\
+		return test_bit(HPG_##flname, (void *)((unsigned long)private));	\
+	}	\
 static inline int HPage##uname(struct page *page)		\
 	{ return test_bit(HPG_##flname, &(page->private)); }
 
 #define SETHPAGEFLAG(uname, flname)				\
+static __always_inline							\
+void folio_set_hugetlb_##flname(struct folio *folio)		\
+	{	void **private = &folio->private;		\
+		set_bit(HPG_##flname, (void *)((unsigned long)private));		\
+	}	\
 static inline void SetHPage##uname(struct page *page)		\
 	{ set_bit(HPG_##flname, &(page->private)); }
 
 #define CLEARHPAGEFLAG(uname, flname)				\
+static __always_inline								\
+void folio_clear_hugetlb_##flname(struct folio *folio)		\
+	{	void **private = &folio->private;		\
+		clear_bit(HPG_##flname, (void *)((unsigned long)private));		\
+	}	\
 static inline void ClearHPage##uname(struct page *page)		\
 	{ clear_bit(HPG_##flname, &(page->private)); }
 #else
 #define TESTHPAGEFLAG(uname, flname)				\
+static inline int folio_test_hugetlb_##flname(struct folio *folio)		\
+	{ return 0; }										\
 static inline int HPage##uname(struct page *page)		\
 	{ return 0; }
 
 #define SETHPAGEFLAG(uname, flname)				\
+static inline void folio_set_hugetlb_##flname(struct folio *folio)		\
+	{ }		                                                \
 static inline void SetHPage##uname(struct page *page)		\
 	{ }
 
 #define CLEARHPAGEFLAG(uname, flname)				\
+static inline void folio_clear_hugetlb_##flname(struct folio *folio)	\
+	{ }		                                                \
 static inline void ClearHPage##uname(struct page *page)		\
 	{ }
 #endif
-- 
2.31.1





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux