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 #if defined(CONFIG_PAGE_IDLE_FLAG) && !defined(CONFIG_64BIT)
11 * If there is not enough space to store Idle and Young bits in page flags, use
12 * page ext flags instead.
14 static inline bool folio_test_young(const struct folio
*folio
)
16 struct page_ext
*page_ext
= page_ext_get(&folio
->page
);
19 if (unlikely(!page_ext
))
22 page_young
= test_bit(PAGE_EXT_YOUNG
, &page_ext
->flags
);
23 page_ext_put(page_ext
);
28 static inline void folio_set_young(struct folio
*folio
)
30 struct page_ext
*page_ext
= page_ext_get(&folio
->page
);
32 if (unlikely(!page_ext
))
35 set_bit(PAGE_EXT_YOUNG
, &page_ext
->flags
);
36 page_ext_put(page_ext
);
39 static inline bool folio_test_clear_young(struct folio
*folio
)
41 struct page_ext
*page_ext
= page_ext_get(&folio
->page
);
44 if (unlikely(!page_ext
))
47 page_young
= test_and_clear_bit(PAGE_EXT_YOUNG
, &page_ext
->flags
);
48 page_ext_put(page_ext
);
53 static inline bool folio_test_idle(const struct folio
*folio
)
55 struct page_ext
*page_ext
= page_ext_get(&folio
->page
);
58 if (unlikely(!page_ext
))
61 page_idle
= test_bit(PAGE_EXT_IDLE
, &page_ext
->flags
);
62 page_ext_put(page_ext
);
67 static inline void folio_set_idle(struct folio
*folio
)
69 struct page_ext
*page_ext
= page_ext_get(&folio
->page
);
71 if (unlikely(!page_ext
))
74 set_bit(PAGE_EXT_IDLE
, &page_ext
->flags
);
75 page_ext_put(page_ext
);
78 static inline void folio_clear_idle(struct folio
*folio
)
80 struct page_ext
*page_ext
= page_ext_get(&folio
->page
);
82 if (unlikely(!page_ext
))
85 clear_bit(PAGE_EXT_IDLE
, &page_ext
->flags
);
86 page_ext_put(page_ext
);
88 #endif /* CONFIG_PAGE_IDLE_FLAG && !64BIT */
89 #endif /* _LINUX_MM_PAGE_IDLE_H */