1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_MM_PAGE_IDLE_H
3 #define _LINUX_MM_PAGE_IDLE_H
5 #include <linux/bitops.h>
6 #include <linux/page-flags.h>
7 #include <linux/page_ext.h>
9 #ifdef CONFIG_IDLE_PAGE_TRACKING
12 static inline bool page_is_young(struct page
*page
)
14 return PageYoung(page
);
17 static inline void set_page_young(struct page
*page
)
22 static inline bool test_and_clear_page_young(struct page
*page
)
24 return TestClearPageYoung(page
);
27 static inline bool page_is_idle(struct page
*page
)
29 return PageIdle(page
);
32 static inline void set_page_idle(struct page
*page
)
37 static inline void clear_page_idle(struct page
*page
)
41 #else /* !CONFIG_64BIT */
43 * If there is not enough space to store Idle and Young bits in page flags, use
44 * page ext flags instead.
46 extern struct page_ext_operations page_idle_ops
;
48 static inline bool page_is_young(struct page
*page
)
50 struct page_ext
*page_ext
= lookup_page_ext(page
);
52 if (unlikely(!page_ext
))
55 return test_bit(PAGE_EXT_YOUNG
, &page_ext
->flags
);
58 static inline void set_page_young(struct page
*page
)
60 struct page_ext
*page_ext
= lookup_page_ext(page
);
62 if (unlikely(!page_ext
))
65 set_bit(PAGE_EXT_YOUNG
, &page_ext
->flags
);
68 static inline bool test_and_clear_page_young(struct page
*page
)
70 struct page_ext
*page_ext
= lookup_page_ext(page
);
72 if (unlikely(!page_ext
))
75 return test_and_clear_bit(PAGE_EXT_YOUNG
, &page_ext
->flags
);
78 static inline bool page_is_idle(struct page
*page
)
80 struct page_ext
*page_ext
= lookup_page_ext(page
);
82 if (unlikely(!page_ext
))
85 return test_bit(PAGE_EXT_IDLE
, &page_ext
->flags
);
88 static inline void set_page_idle(struct page
*page
)
90 struct page_ext
*page_ext
= lookup_page_ext(page
);
92 if (unlikely(!page_ext
))
95 set_bit(PAGE_EXT_IDLE
, &page_ext
->flags
);
98 static inline void clear_page_idle(struct page
*page
)
100 struct page_ext
*page_ext
= lookup_page_ext(page
);
102 if (unlikely(!page_ext
))
105 clear_bit(PAGE_EXT_IDLE
, &page_ext
->flags
);
107 #endif /* CONFIG_64BIT */
109 #else /* !CONFIG_IDLE_PAGE_TRACKING */
111 static inline bool page_is_young(struct page
*page
)
116 static inline void set_page_young(struct page
*page
)
120 static inline bool test_and_clear_page_young(struct page
*page
)
125 static inline bool page_is_idle(struct page
*page
)
130 static inline void set_page_idle(struct page
*page
)
134 static inline void clear_page_idle(struct page
*page
)
138 #endif /* CONFIG_IDLE_PAGE_TRACKING */
140 #endif /* _LINUX_MM_PAGE_IDLE_H */