@@ -458,30 +458,51 @@ static __always_inline int TestClearPage##uname(struct page *page) \
458458 TESTSETFLAG(uname, lname, policy) \
459459 TESTCLEARFLAG(uname, lname, policy)
460460
461+ #define FOLIO_TEST_FLAG_FALSE (name ) \
462+ static inline bool folio_test_##name(const struct folio *folio) \
463+ { return false; }
464+ #define FOLIO_SET_FLAG_NOOP (name ) \
465+ static inline void folio_set_##name(struct folio *folio) { }
466+ #define FOLIO_CLEAR_FLAG_NOOP (name ) \
467+ static inline void folio_clear_##name(struct folio *folio) { }
468+ #define __FOLIO_SET_FLAG_NOOP (name ) \
469+ static inline void __folio_set_##name(struct folio *folio) { }
470+ #define __FOLIO_CLEAR_FLAG_NOOP (name ) \
471+ static inline void __folio_clear_##name(struct folio *folio) { }
472+ #define FOLIO_TEST_SET_FLAG_FALSE (name ) \
473+ static inline bool folio_test_set_##name(struct folio *folio) \
474+ { return false; }
475+ #define FOLIO_TEST_CLEAR_FLAG_FALSE (name ) \
476+ static inline bool folio_test_clear_##name(struct folio *folio) \
477+ { return false; }
478+
479+ #define FOLIO_FLAG_FALSE (name ) \
480+ FOLIO_TEST_FLAG_FALSE(name) \
481+ FOLIO_SET_FLAG_NOOP(name) \
482+ FOLIO_CLEAR_FLAG_NOOP(name)
483+
461484#define TESTPAGEFLAG_FALSE (uname , lname ) \
462- static inline bool folio_test_##lname(const struct folio *folio) { return false; } \
485+ FOLIO_TEST_FLAG_FALSE(lname) \
463486static inline int Page##uname(const struct page *page) { return 0; }
464487
465488#define SETPAGEFLAG_NOOP (uname , lname ) \
466- static inline void folio_set_##lname(struct folio *folio) { } \
489+ FOLIO_SET_FLAG_NOOP(lname) \
467490static inline void SetPage##uname(struct page *page) { }
468491
469492#define CLEARPAGEFLAG_NOOP (uname , lname ) \
470- static inline void folio_clear_##lname(struct folio *folio) { } \
493+ FOLIO_CLEAR_FLAG_NOOP(lname) \
471494static inline void ClearPage##uname(struct page *page) { }
472495
473496#define __CLEARPAGEFLAG_NOOP (uname , lname ) \
474- static inline void __folio_clear_##lname(struct folio *folio) { } \
497+ __FOLIO_CLEAR_FLAG_NOOP(lname) \
475498static inline void __ClearPage##uname(struct page *page) { }
476499
477500#define TESTSETFLAG_FALSE (uname , lname ) \
478- static inline bool folio_test_set_##lname(struct folio *folio) \
479- { return 0; } \
501+ FOLIO_TEST_SET_FLAG_FALSE(lname) \
480502static inline int TestSetPage##uname(struct page *page) { return 0; }
481503
482504#define TESTCLEARFLAG_FALSE (uname , lname ) \
483- static inline bool folio_test_clear_##lname(struct folio *folio) \
484- { return 0; } \
505+ FOLIO_TEST_CLEAR_FLAG_FALSE(lname) \
485506static inline int TestClearPage##uname(struct page *page) { return 0; }
486507
487508#define PAGEFLAG_FALSE (uname , lname ) TESTPAGEFLAG_FALSE(uname, lname) \
@@ -977,35 +998,38 @@ static inline int page_has_type(const struct page *page)
977998 return page_type_has_type (page -> page_type );
978999}
9791000
1001+ #define FOLIO_TYPE_OPS (lname , fname ) \
1002+ static __always_inline bool folio_test_##fname(const struct folio *folio)\
1003+ { \
1004+ return folio_test_type(folio, PG_##lname); \
1005+ } \
1006+ static __always_inline void __folio_set_##fname(struct folio *folio) \
1007+ { \
1008+ VM_BUG_ON_FOLIO(!folio_test_type(folio, 0), folio); \
1009+ folio->page.page_type &= ~PG_##lname; \
1010+ } \
1011+ static __always_inline void __folio_clear_##fname(struct folio *folio) \
1012+ { \
1013+ VM_BUG_ON_FOLIO(!folio_test_##fname(folio), folio); \
1014+ folio->page.page_type |= PG_##lname; \
1015+ }
1016+
9801017#define PAGE_TYPE_OPS (uname , lname , fname ) \
1018+ FOLIO_TYPE_OPS(lname, fname) \
9811019static __always_inline int Page##uname(const struct page *page) \
9821020{ \
9831021 return PageType(page, PG_##lname); \
9841022} \
985- static __always_inline int folio_test_##fname(const struct folio *folio)\
986- { \
987- return folio_test_type(folio, PG_##lname); \
988- } \
9891023static __always_inline void __SetPage##uname(struct page *page) \
9901024{ \
9911025 VM_BUG_ON_PAGE(!PageType(page, 0), page); \
9921026 page->page_type &= ~PG_##lname; \
9931027} \
994- static __always_inline void __folio_set_##fname(struct folio *folio) \
995- { \
996- VM_BUG_ON_FOLIO(!folio_test_type(folio, 0), folio); \
997- folio->page.page_type &= ~PG_##lname; \
998- } \
9991028static __always_inline void __ClearPage##uname(struct page *page) \
10001029{ \
10011030 VM_BUG_ON_PAGE(!Page##uname(page), page); \
10021031 page->page_type |= PG_##lname; \
1003- } \
1004- static __always_inline void __folio_clear_##fname(struct folio *folio) \
1005- { \
1006- VM_BUG_ON_FOLIO(!folio_test_##fname(folio), folio); \
1007- folio->page.page_type |= PG_##lname; \
1008- } \
1032+ }
10091033
10101034/*
10111035 * PageBuddy() indicates that the page is free and in the buddy system
0 commit comments