1
2
3
4
5#ifndef PAGE_FLAGS_H
6#define PAGE_FLAGS_H
7
8#include <linux/types.h>
9#ifndef __GENERATING_BOUNDS_H
10#include <linux/mm_types.h>
11#include <linux/bounds.h>
12#endif
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72enum pageflags {
73 PG_locked,
74 PG_error,
75 PG_referenced,
76 PG_uptodate,
77 PG_dirty,
78 PG_lru,
79 PG_active,
80 PG_slab,
81 PG_owner_priv_1,
82 PG_arch_1,
83 PG_reserved,
84 PG_private,
85 PG_writeback,
86#ifdef CONFIG_PAGEFLAGS_EXTENDED
87 PG_head,
88 PG_tail,
89#else
90 PG_compound,
91#endif
92 PG_swapcache,
93 PG_mappedtodisk,
94 PG_reclaim,
95 PG_buddy,
96#ifdef CONFIG_IA64_UNCACHED_ALLOCATOR
97 PG_uncached,
98#endif
99 __NR_PAGEFLAGS,
100
101
102 PG_checked = PG_owner_priv_1,
103
104
105 PG_pinned = PG_owner_priv_1,
106 PG_savepinned = PG_dirty,
107
108
109 PG_slob_page = PG_active,
110 PG_slob_free = PG_private,
111
112
113 PG_slub_frozen = PG_active,
114 PG_slub_debug = PG_error,
115};
116
117#ifndef __GENERATING_BOUNDS_H
118
119
120
121
122#define TESTPAGEFLAG(uname, lname) \
123static inline int Page##uname(struct page *page) \
124 { return test_bit(PG_##lname, &page->flags); }
125
126#define SETPAGEFLAG(uname, lname) \
127static inline void SetPage##uname(struct page *page) \
128 { set_bit(PG_##lname, &page->flags); }
129
130#define CLEARPAGEFLAG(uname, lname) \
131static inline void ClearPage##uname(struct page *page) \
132 { clear_bit(PG_##lname, &page->flags); }
133
134#define __SETPAGEFLAG(uname, lname) \
135static inline void __SetPage##uname(struct page *page) \
136 { __set_bit(PG_##lname, &page->flags); }
137
138#define __CLEARPAGEFLAG(uname, lname) \
139static inline void __ClearPage##uname(struct page *page) \
140 { __clear_bit(PG_##lname, &page->flags); }
141
142#define TESTSETFLAG(uname, lname) \
143static inline int TestSetPage##uname(struct page *page) \
144 { return test_and_set_bit(PG_##lname, &page->flags); }
145
146#define TESTCLEARFLAG(uname, lname) \
147static inline int TestClearPage##uname(struct page *page) \
148 { return test_and_clear_bit(PG_##lname, &page->flags); }
149
150
151#define PAGEFLAG(uname, lname) TESTPAGEFLAG(uname, lname) \
152 SETPAGEFLAG(uname, lname) CLEARPAGEFLAG(uname, lname)
153
154#define __PAGEFLAG(uname, lname) TESTPAGEFLAG(uname, lname) \
155 __SETPAGEFLAG(uname, lname) __CLEARPAGEFLAG(uname, lname)
156
157#define PAGEFLAG_FALSE(uname) \
158static inline int Page##uname(struct page *page) \
159 { return 0; }
160
161#define TESTSCFLAG(uname, lname) \
162 TESTSETFLAG(uname, lname) TESTCLEARFLAG(uname, lname)
163
164struct page;
165
166TESTPAGEFLAG(Locked, locked)
167PAGEFLAG(Error, error)
168PAGEFLAG(Referenced, referenced) TESTCLEARFLAG(Referenced, referenced)
169PAGEFLAG(Dirty, dirty) TESTSCFLAG(Dirty, dirty) __CLEARPAGEFLAG(Dirty, dirty)
170PAGEFLAG(LRU, lru) __CLEARPAGEFLAG(LRU, lru)
171PAGEFLAG(Active, active) __CLEARPAGEFLAG(Active, active)
172__PAGEFLAG(Slab, slab)
173PAGEFLAG(Checked, checked)
174PAGEFLAG(Pinned, pinned) TESTSCFLAG(Pinned, pinned)
175PAGEFLAG(SavePinned, savepinned);
176PAGEFLAG(Reserved, reserved) __CLEARPAGEFLAG(Reserved, reserved)
177PAGEFLAG(Private, private) __CLEARPAGEFLAG(Private, private)
178 __SETPAGEFLAG(Private, private)
179
180__PAGEFLAG(SlobPage, slob_page)
181__PAGEFLAG(SlobFree, slob_free)
182
183__PAGEFLAG(SlubFrozen, slub_frozen)
184__PAGEFLAG(SlubDebug, slub_debug)
185
186
187
188
189
190TESTPAGEFLAG(Writeback, writeback) TESTSCFLAG(Writeback, writeback)
191__PAGEFLAG(Buddy, buddy)
192PAGEFLAG(MappedToDisk, mappedtodisk)
193
194
195PAGEFLAG(Reclaim, reclaim) TESTCLEARFLAG(Reclaim, reclaim)
196PAGEFLAG(Readahead, reclaim)
197
198#ifdef CONFIG_HIGHMEM
199
200
201
202
203#define PageHighMem(__p) is_highmem(page_zone(__p))
204#else
205PAGEFLAG_FALSE(HighMem)
206#endif
207
208#ifdef CONFIG_SWAP
209PAGEFLAG(SwapCache, swapcache)
210#else
211PAGEFLAG_FALSE(SwapCache)
212#endif
213
214#ifdef CONFIG_IA64_UNCACHED_ALLOCATOR
215PAGEFLAG(Uncached, uncached)
216#else
217PAGEFLAG_FALSE(Uncached)
218#endif
219
220static inline int PageUptodate(struct page *page)
221{
222 int ret = test_bit(PG_uptodate, &(page)->flags);
223
224
225
226
227
228
229
230
231
232 if (ret)
233 smp_rmb();
234
235 return ret;
236}
237
238static inline void __SetPageUptodate(struct page *page)
239{
240 smp_wmb();
241 __set_bit(PG_uptodate, &(page)->flags);
242}
243
244static inline void SetPageUptodate(struct page *page)
245{
246#ifdef CONFIG_S390
247 if (!test_and_set_bit(PG_uptodate, &page->flags))
248 page_clear_dirty(page);
249#else
250
251
252
253
254
255
256
257
258 smp_wmb();
259 set_bit(PG_uptodate, &(page)->flags);
260#endif
261}
262
263CLEARPAGEFLAG(Uptodate, uptodate)
264
265extern void cancel_dirty_page(struct page *page, unsigned int account_size);
266
267int test_clear_page_writeback(struct page *page);
268int test_set_page_writeback(struct page *page);
269
270static inline void set_page_writeback(struct page *page)
271{
272 test_set_page_writeback(page);
273}
274
275#ifdef CONFIG_PAGEFLAGS_EXTENDED
276
277
278
279
280
281
282__PAGEFLAG(Head, head)
283__PAGEFLAG(Tail, tail)
284
285static inline int PageCompound(struct page *page)
286{
287 return page->flags & ((1L << PG_head) | (1L << PG_tail));
288
289}
290#else
291
292
293
294
295
296
297TESTPAGEFLAG(Compound, compound)
298__PAGEFLAG(Head, compound)
299
300
301
302
303
304
305
306
307
308
309
310#define PG_head_tail_mask ((1L << PG_compound) | (1L << PG_reclaim))
311
312static inline int PageTail(struct page *page)
313{
314 return ((page->flags & PG_head_tail_mask) == PG_head_tail_mask);
315}
316
317static inline void __SetPageTail(struct page *page)
318{
319 page->flags |= PG_head_tail_mask;
320}
321
322static inline void __ClearPageTail(struct page *page)
323{
324 page->flags &= ~PG_head_tail_mask;
325}
326
327#endif
328
329#define PAGE_FLAGS (1 << PG_lru | 1 << PG_private | 1 << PG_locked | \
330 1 << PG_buddy | 1 << PG_writeback | \
331 1 << PG_slab | 1 << PG_swapcache | 1 << PG_active)
332
333
334
335
336
337#define PAGE_FLAGS_CLEAR_WHEN_BAD (PAGE_FLAGS | 1 << PG_reclaim | 1 << PG_dirty)
338
339
340
341
342
343#define PAGE_FLAGS_CHECK_AT_FREE (PAGE_FLAGS | 1 << PG_reserved)
344
345
346
347
348
349
350#define PAGE_FLAGS_CHECK_AT_PREP (PAGE_FLAGS | 1 << PG_reserved | 1 << PG_dirty)
351
352#endif
353#endif
354