@@ -458,30 +458,51 @@ static __always_inline int TestClearPage##uname(struct page *page) \
458
458
TESTSETFLAG(uname, lname, policy) \
459
459
TESTCLEARFLAG(uname, lname, policy)
460
460
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
+
461
484
#define TESTPAGEFLAG_FALSE (uname , lname ) \
462
- static inline bool folio_test_##lname(const struct folio *folio) { return false; } \
485
+ FOLIO_TEST_FLAG_FALSE(lname) \
463
486
static inline int Page##uname(const struct page *page) { return 0; }
464
487
465
488
#define SETPAGEFLAG_NOOP (uname , lname ) \
466
- static inline void folio_set_##lname(struct folio *folio) { } \
489
+ FOLIO_SET_FLAG_NOOP(lname) \
467
490
static inline void SetPage##uname(struct page *page) { }
468
491
469
492
#define CLEARPAGEFLAG_NOOP (uname , lname ) \
470
- static inline void folio_clear_##lname(struct folio *folio) { } \
493
+ FOLIO_CLEAR_FLAG_NOOP(lname) \
471
494
static inline void ClearPage##uname(struct page *page) { }
472
495
473
496
#define __CLEARPAGEFLAG_NOOP (uname , lname ) \
474
- static inline void __folio_clear_##lname(struct folio *folio) { } \
497
+ __FOLIO_CLEAR_FLAG_NOOP(lname) \
475
498
static inline void __ClearPage##uname(struct page *page) { }
476
499
477
500
#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) \
480
502
static inline int TestSetPage##uname(struct page *page) { return 0; }
481
503
482
504
#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) \
485
506
static inline int TestClearPage##uname(struct page *page) { return 0; }
486
507
487
508
#define PAGEFLAG_FALSE (uname , lname ) TESTPAGEFLAG_FALSE(uname, lname) \
@@ -977,35 +998,38 @@ static inline int page_has_type(const struct page *page)
977
998
return page_type_has_type (page -> page_type );
978
999
}
979
1000
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
+
980
1017
#define PAGE_TYPE_OPS (uname , lname , fname ) \
1018
+ FOLIO_TYPE_OPS(lname, fname) \
981
1019
static __always_inline int Page##uname(const struct page *page) \
982
1020
{ \
983
1021
return PageType(page, PG_##lname); \
984
1022
} \
985
- static __always_inline int folio_test_##fname(const struct folio *folio)\
986
- { \
987
- return folio_test_type(folio, PG_##lname); \
988
- } \
989
1023
static __always_inline void __SetPage##uname(struct page *page) \
990
1024
{ \
991
1025
VM_BUG_ON_PAGE(!PageType(page, 0), page); \
992
1026
page->page_type &= ~PG_##lname; \
993
1027
} \
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
- } \
999
1028
static __always_inline void __ClearPage##uname(struct page *page) \
1000
1029
{ \
1001
1030
VM_BUG_ON_PAGE(!Page##uname(page), page); \
1002
1031
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
+ }
1009
1033
1010
1034
/*
1011
1035
* PageBuddy() indicates that the page is free and in the buddy system
0 commit comments