]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - include/linux/page_idle.h
ACPI: fix acpi_find_child_device() invocation in acpi_preset_companion()
[mirror_ubuntu-bionic-kernel.git] / include / linux / page_idle.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
33c3fc71
VD
2#ifndef _LINUX_MM_PAGE_IDLE_H
3#define _LINUX_MM_PAGE_IDLE_H
4
5#include <linux/bitops.h>
6#include <linux/page-flags.h>
7#include <linux/page_ext.h>
8
9#ifdef CONFIG_IDLE_PAGE_TRACKING
10
11#ifdef CONFIG_64BIT
12static inline bool page_is_young(struct page *page)
13{
14 return PageYoung(page);
15}
16
17static inline void set_page_young(struct page *page)
18{
19 SetPageYoung(page);
20}
21
22static inline bool test_and_clear_page_young(struct page *page)
23{
24 return TestClearPageYoung(page);
25}
26
27static inline bool page_is_idle(struct page *page)
28{
29 return PageIdle(page);
30}
31
32static inline void set_page_idle(struct page *page)
33{
34 SetPageIdle(page);
35}
36
37static inline void clear_page_idle(struct page *page)
38{
39 ClearPageIdle(page);
40}
41#else /* !CONFIG_64BIT */
42/*
43 * If there is not enough space to store Idle and Young bits in page flags, use
44 * page ext flags instead.
45 */
46extern struct page_ext_operations page_idle_ops;
47
48static inline bool page_is_young(struct page *page)
49{
f86e4271
YS
50 struct page_ext *page_ext = lookup_page_ext(page);
51
52 if (unlikely(!page_ext))
53 return false;
54
55 return test_bit(PAGE_EXT_YOUNG, &page_ext->flags);
33c3fc71
VD
56}
57
58static inline void set_page_young(struct page *page)
59{
f86e4271
YS
60 struct page_ext *page_ext = lookup_page_ext(page);
61
62 if (unlikely(!page_ext))
63 return;
64
65 set_bit(PAGE_EXT_YOUNG, &page_ext->flags);
33c3fc71
VD
66}
67
68static inline bool test_and_clear_page_young(struct page *page)
69{
f86e4271
YS
70 struct page_ext *page_ext = lookup_page_ext(page);
71
72 if (unlikely(!page_ext))
73 return false;
74
75 return test_and_clear_bit(PAGE_EXT_YOUNG, &page_ext->flags);
33c3fc71
VD
76}
77
78static inline bool page_is_idle(struct page *page)
79{
f86e4271
YS
80 struct page_ext *page_ext = lookup_page_ext(page);
81
82 if (unlikely(!page_ext))
83 return false;
84
85 return test_bit(PAGE_EXT_IDLE, &page_ext->flags);
33c3fc71
VD
86}
87
88static inline void set_page_idle(struct page *page)
89{
f86e4271
YS
90 struct page_ext *page_ext = lookup_page_ext(page);
91
92 if (unlikely(!page_ext))
93 return;
94
95 set_bit(PAGE_EXT_IDLE, &page_ext->flags);
33c3fc71
VD
96}
97
98static inline void clear_page_idle(struct page *page)
99{
f86e4271
YS
100 struct page_ext *page_ext = lookup_page_ext(page);
101
102 if (unlikely(!page_ext))
103 return;
104
105 clear_bit(PAGE_EXT_IDLE, &page_ext->flags);
33c3fc71
VD
106}
107#endif /* CONFIG_64BIT */
108
109#else /* !CONFIG_IDLE_PAGE_TRACKING */
110
111static inline bool page_is_young(struct page *page)
112{
113 return false;
114}
115
116static inline void set_page_young(struct page *page)
117{
118}
119
120static inline bool test_and_clear_page_young(struct page *page)
121{
122 return false;
123}
124
125static inline bool page_is_idle(struct page *page)
126{
127 return false;
128}
129
130static inline void set_page_idle(struct page *page)
131{
132}
133
134static inline void clear_page_idle(struct page *page)
135{
136}
137
138#endif /* CONFIG_IDLE_PAGE_TRACKING */
139
140#endif /* _LINUX_MM_PAGE_IDLE_H */