Vladimir Davydov | 33c3fc7 | 2015-09-09 15:35:45 -0700 | [diff] [blame] | 1 | #ifndef _LINUX_MM_PAGE_IDLE_H |
| 2 | #define _LINUX_MM_PAGE_IDLE_H |
| 3 | |
| 4 | #include <linux/bitops.h> |
| 5 | #include <linux/page-flags.h> |
| 6 | #include <linux/page_ext.h> |
| 7 | |
| 8 | #ifdef CONFIG_IDLE_PAGE_TRACKING |
| 9 | |
| 10 | #ifdef CONFIG_64BIT |
| 11 | static inline bool page_is_young(struct page *page) |
| 12 | { |
| 13 | return PageYoung(page); |
| 14 | } |
| 15 | |
| 16 | static inline void set_page_young(struct page *page) |
| 17 | { |
| 18 | SetPageYoung(page); |
| 19 | } |
| 20 | |
| 21 | static inline bool test_and_clear_page_young(struct page *page) |
| 22 | { |
| 23 | return TestClearPageYoung(page); |
| 24 | } |
| 25 | |
| 26 | static inline bool page_is_idle(struct page *page) |
| 27 | { |
| 28 | return PageIdle(page); |
| 29 | } |
| 30 | |
| 31 | static inline void set_page_idle(struct page *page) |
| 32 | { |
| 33 | SetPageIdle(page); |
| 34 | } |
| 35 | |
| 36 | static inline void clear_page_idle(struct page *page) |
| 37 | { |
| 38 | ClearPageIdle(page); |
| 39 | } |
| 40 | #else /* !CONFIG_64BIT */ |
| 41 | /* |
| 42 | * If there is not enough space to store Idle and Young bits in page flags, use |
| 43 | * page ext flags instead. |
| 44 | */ |
| 45 | extern struct page_ext_operations page_idle_ops; |
| 46 | |
| 47 | static inline bool page_is_young(struct page *page) |
| 48 | { |
| 49 | return test_bit(PAGE_EXT_YOUNG, &lookup_page_ext(page)->flags); |
| 50 | } |
| 51 | |
| 52 | static inline void set_page_young(struct page *page) |
| 53 | { |
| 54 | set_bit(PAGE_EXT_YOUNG, &lookup_page_ext(page)->flags); |
| 55 | } |
| 56 | |
| 57 | static inline bool test_and_clear_page_young(struct page *page) |
| 58 | { |
| 59 | return test_and_clear_bit(PAGE_EXT_YOUNG, |
| 60 | &lookup_page_ext(page)->flags); |
| 61 | } |
| 62 | |
| 63 | static inline bool page_is_idle(struct page *page) |
| 64 | { |
| 65 | return test_bit(PAGE_EXT_IDLE, &lookup_page_ext(page)->flags); |
| 66 | } |
| 67 | |
| 68 | static inline void set_page_idle(struct page *page) |
| 69 | { |
| 70 | set_bit(PAGE_EXT_IDLE, &lookup_page_ext(page)->flags); |
| 71 | } |
| 72 | |
| 73 | static inline void clear_page_idle(struct page *page) |
| 74 | { |
| 75 | clear_bit(PAGE_EXT_IDLE, &lookup_page_ext(page)->flags); |
| 76 | } |
| 77 | #endif /* CONFIG_64BIT */ |
| 78 | |
| 79 | #else /* !CONFIG_IDLE_PAGE_TRACKING */ |
| 80 | |
| 81 | static inline bool page_is_young(struct page *page) |
| 82 | { |
| 83 | return false; |
| 84 | } |
| 85 | |
| 86 | static inline void set_page_young(struct page *page) |
| 87 | { |
| 88 | } |
| 89 | |
| 90 | static inline bool test_and_clear_page_young(struct page *page) |
| 91 | { |
| 92 | return false; |
| 93 | } |
| 94 | |
| 95 | static inline bool page_is_idle(struct page *page) |
| 96 | { |
| 97 | return false; |
| 98 | } |
| 99 | |
| 100 | static inline void set_page_idle(struct page *page) |
| 101 | { |
| 102 | } |
| 103 | |
| 104 | static inline void clear_page_idle(struct page *page) |
| 105 | { |
| 106 | } |
| 107 | |
| 108 | #endif /* CONFIG_IDLE_PAGE_TRACKING */ |
| 109 | |
| 110 | #endif /* _LINUX_MM_PAGE_IDLE_H */ |