Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
[cris-mirror.git] / include / linux / page_idle.h
blob1e894d34bdceb2a91318bd1ea7796a17deeddf8b
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
11 #ifdef CONFIG_64BIT
12 static inline bool page_is_young(struct page *page)
14 return PageYoung(page);
17 static inline void set_page_young(struct page *page)
19 SetPageYoung(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)
34 SetPageIdle(page);
37 static inline void clear_page_idle(struct page *page)
39 ClearPageIdle(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))
53 return false;
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))
63 return;
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))
73 return false;
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))
83 return false;
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))
93 return;
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))
103 return;
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)
113 return false;
116 static inline void set_page_young(struct page *page)
120 static inline bool test_and_clear_page_young(struct page *page)
122 return false;
125 static inline bool page_is_idle(struct page *page)
127 return false;
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 */