aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/page-flags.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /include/linux/page-flags.h
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'include/linux/page-flags.h')
-rw-r--r--include/linux/page-flags.h324
1 files changed, 324 insertions, 0 deletions
diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
new file mode 100644
index 000000000000..6b74fcf5bb63
--- /dev/null
+++ b/include/linux/page-flags.h
@@ -0,0 +1,324 @@
1/*
2 * Macros for manipulating and testing page->flags
3 */
4
5#ifndef PAGE_FLAGS_H
6#define PAGE_FLAGS_H
7
8#include <linux/percpu.h>
9#include <linux/cache.h>
10#include <asm/pgtable.h>
11
12/*
13 * Various page->flags bits:
14 *
15 * PG_reserved is set for special pages, which can never be swapped out. Some
16 * of them might not even exist (eg empty_bad_page)...
17 *
18 * The PG_private bitflag is set if page->private contains a valid value.
19 *
20 * During disk I/O, PG_locked is used. This bit is set before I/O and
21 * reset when I/O completes. page_waitqueue(page) is a wait queue of all tasks
22 * waiting for the I/O on this page to complete.
23 *
24 * PG_uptodate tells whether the page's contents is valid. When a read
25 * completes, the page becomes uptodate, unless a disk I/O error happened.
26 *
27 * For choosing which pages to swap out, inode pages carry a PG_referenced bit,
28 * which is set any time the system accesses that page through the (mapping,
29 * index) hash table. This referenced bit, together with the referenced bit
30 * in the page tables, is used to manipulate page->age and move the page across
31 * the active, inactive_dirty and inactive_clean lists.
32 *
33 * Note that the referenced bit, the page->lru list_head and the active,
34 * inactive_dirty and inactive_clean lists are protected by the
35 * zone->lru_lock, and *NOT* by the usual PG_locked bit!
36 *
37 * PG_error is set to indicate that an I/O error occurred on this page.
38 *
39 * PG_arch_1 is an architecture specific page state bit. The generic code
40 * guarantees that this bit is cleared for a page when it first is entered into
41 * the page cache.
42 *
43 * PG_highmem pages are not permanently mapped into the kernel virtual address
44 * space, they need to be kmapped separately for doing IO on the pages. The
45 * struct page (these bits with information) are always mapped into kernel
46 * address space...
47 */
48
49/*
50 * Don't use the *_dontuse flags. Use the macros. Otherwise you'll break
51 * locked- and dirty-page accounting. The top eight bits of page->flags are
52 * used for page->zone, so putting flag bits there doesn't work.
53 */
54#define PG_locked 0 /* Page is locked. Don't touch. */
55#define PG_error 1
56#define PG_referenced 2
57#define PG_uptodate 3
58
59#define PG_dirty 4
60#define PG_lru 5
61#define PG_active 6
62#define PG_slab 7 /* slab debug (Suparna wants this) */
63
64#define PG_highmem 8
65#define PG_checked 9 /* kill me in 2.5.<early>. */
66#define PG_arch_1 10
67#define PG_reserved 11
68
69#define PG_private 12 /* Has something at ->private */
70#define PG_writeback 13 /* Page is under writeback */
71#define PG_nosave 14 /* Used for system suspend/resume */
72#define PG_compound 15 /* Part of a compound page */
73
74#define PG_swapcache 16 /* Swap page: swp_entry_t in private */
75#define PG_mappedtodisk 17 /* Has blocks allocated on-disk */
76#define PG_reclaim 18 /* To be reclaimed asap */
77#define PG_nosave_free 19 /* Free, should not be written */
78#define PG_uncached 20 /* Page has been mapped as uncached */
79
80/*
81 * Global page accounting. One instance per CPU. Only unsigned longs are
82 * allowed.
83 */
84struct page_state {
85 unsigned long nr_dirty; /* Dirty writeable pages */
86 unsigned long nr_writeback; /* Pages under writeback */
87 unsigned long nr_unstable; /* NFS unstable pages */
88 unsigned long nr_page_table_pages;/* Pages used for pagetables */
89 unsigned long nr_mapped; /* mapped into pagetables */
90 unsigned long nr_slab; /* In slab */
91#define GET_PAGE_STATE_LAST nr_slab
92
93 /*
94 * The below are zeroed by get_page_state(). Use get_full_page_state()
95 * to add up all these.
96 */
97 unsigned long pgpgin; /* Disk reads */
98 unsigned long pgpgout; /* Disk writes */
99 unsigned long pswpin; /* swap reads */
100 unsigned long pswpout; /* swap writes */
101 unsigned long pgalloc_high; /* page allocations */
102
103 unsigned long pgalloc_normal;
104 unsigned long pgalloc_dma;
105 unsigned long pgfree; /* page freeings */
106 unsigned long pgactivate; /* pages moved inactive->active */
107 unsigned long pgdeactivate; /* pages moved active->inactive */
108
109 unsigned long pgfault; /* faults (major+minor) */
110 unsigned long pgmajfault; /* faults (major only) */
111 unsigned long pgrefill_high; /* inspected in refill_inactive_zone */
112 unsigned long pgrefill_normal;
113 unsigned long pgrefill_dma;
114
115 unsigned long pgsteal_high; /* total highmem pages reclaimed */
116 unsigned long pgsteal_normal;
117 unsigned long pgsteal_dma;
118 unsigned long pgscan_kswapd_high;/* total highmem pages scanned */
119 unsigned long pgscan_kswapd_normal;
120
121 unsigned long pgscan_kswapd_dma;
122 unsigned long pgscan_direct_high;/* total highmem pages scanned */
123 unsigned long pgscan_direct_normal;
124 unsigned long pgscan_direct_dma;
125 unsigned long pginodesteal; /* pages reclaimed via inode freeing */
126
127 unsigned long slabs_scanned; /* slab objects scanned */
128 unsigned long kswapd_steal; /* pages reclaimed by kswapd */
129 unsigned long kswapd_inodesteal;/* reclaimed via kswapd inode freeing */
130 unsigned long pageoutrun; /* kswapd's calls to page reclaim */
131 unsigned long allocstall; /* direct reclaim calls */
132
133 unsigned long pgrotated; /* pages rotated to tail of the LRU */
134};
135
136extern void get_page_state(struct page_state *ret);
137extern void get_full_page_state(struct page_state *ret);
138extern unsigned long __read_page_state(unsigned offset);
139extern void __mod_page_state(unsigned offset, unsigned long delta);
140
141#define read_page_state(member) \
142 __read_page_state(offsetof(struct page_state, member))
143
144#define mod_page_state(member, delta) \
145 __mod_page_state(offsetof(struct page_state, member), (delta))
146
147#define inc_page_state(member) mod_page_state(member, 1UL)
148#define dec_page_state(member) mod_page_state(member, 0UL - 1)
149#define add_page_state(member,delta) mod_page_state(member, (delta))
150#define sub_page_state(member,delta) mod_page_state(member, 0UL - (delta))
151
152#define mod_page_state_zone(zone, member, delta) \
153 do { \
154 unsigned offset; \
155 if (is_highmem(zone)) \
156 offset = offsetof(struct page_state, member##_high); \
157 else if (is_normal(zone)) \
158 offset = offsetof(struct page_state, member##_normal); \
159 else \
160 offset = offsetof(struct page_state, member##_dma); \
161 __mod_page_state(offset, (delta)); \
162 } while (0)
163
164/*
165 * Manipulation of page state flags
166 */
167#define PageLocked(page) \
168 test_bit(PG_locked, &(page)->flags)
169#define SetPageLocked(page) \
170 set_bit(PG_locked, &(page)->flags)
171#define TestSetPageLocked(page) \
172 test_and_set_bit(PG_locked, &(page)->flags)
173#define ClearPageLocked(page) \
174 clear_bit(PG_locked, &(page)->flags)
175#define TestClearPageLocked(page) \
176 test_and_clear_bit(PG_locked, &(page)->flags)
177
178#define PageError(page) test_bit(PG_error, &(page)->flags)
179#define SetPageError(page) set_bit(PG_error, &(page)->flags)
180#define ClearPageError(page) clear_bit(PG_error, &(page)->flags)
181
182#define PageReferenced(page) test_bit(PG_referenced, &(page)->flags)
183#define SetPageReferenced(page) set_bit(PG_referenced, &(page)->flags)
184#define ClearPageReferenced(page) clear_bit(PG_referenced, &(page)->flags)
185#define TestClearPageReferenced(page) test_and_clear_bit(PG_referenced, &(page)->flags)
186
187#define PageUptodate(page) test_bit(PG_uptodate, &(page)->flags)
188#ifndef SetPageUptodate
189#define SetPageUptodate(page) set_bit(PG_uptodate, &(page)->flags)
190#endif
191#define ClearPageUptodate(page) clear_bit(PG_uptodate, &(page)->flags)
192
193#define PageDirty(page) test_bit(PG_dirty, &(page)->flags)
194#define SetPageDirty(page) set_bit(PG_dirty, &(page)->flags)
195#define TestSetPageDirty(page) test_and_set_bit(PG_dirty, &(page)->flags)
196#define ClearPageDirty(page) clear_bit(PG_dirty, &(page)->flags)
197#define TestClearPageDirty(page) test_and_clear_bit(PG_dirty, &(page)->flags)
198
199#define SetPageLRU(page) set_bit(PG_lru, &(page)->flags)
200#define PageLRU(page) test_bit(PG_lru, &(page)->flags)
201#define TestSetPageLRU(page) test_and_set_bit(PG_lru, &(page)->flags)
202#define TestClearPageLRU(page) test_and_clear_bit(PG_lru, &(page)->flags)
203
204#define PageActive(page) test_bit(PG_active, &(page)->flags)
205#define SetPageActive(page) set_bit(PG_active, &(page)->flags)
206#define ClearPageActive(page) clear_bit(PG_active, &(page)->flags)
207#define TestClearPageActive(page) test_and_clear_bit(PG_active, &(page)->flags)
208#define TestSetPageActive(page) test_and_set_bit(PG_active, &(page)->flags)
209
210#define PageSlab(page) test_bit(PG_slab, &(page)->flags)
211#define SetPageSlab(page) set_bit(PG_slab, &(page)->flags)
212#define ClearPageSlab(page) clear_bit(PG_slab, &(page)->flags)
213#define TestClearPageSlab(page) test_and_clear_bit(PG_slab, &(page)->flags)
214#define TestSetPageSlab(page) test_and_set_bit(PG_slab, &(page)->flags)
215
216#ifdef CONFIG_HIGHMEM
217#define PageHighMem(page) test_bit(PG_highmem, &(page)->flags)
218#else
219#define PageHighMem(page) 0 /* needed to optimize away at compile time */
220#endif
221
222#define PageChecked(page) test_bit(PG_checked, &(page)->flags)
223#define SetPageChecked(page) set_bit(PG_checked, &(page)->flags)
224#define ClearPageChecked(page) clear_bit(PG_checked, &(page)->flags)
225
226#define PageReserved(page) test_bit(PG_reserved, &(page)->flags)
227#define SetPageReserved(page) set_bit(PG_reserved, &(page)->flags)
228#define ClearPageReserved(page) clear_bit(PG_reserved, &(page)->flags)
229#define __ClearPageReserved(page) __clear_bit(PG_reserved, &(page)->flags)
230
231#define SetPagePrivate(page) set_bit(PG_private, &(page)->flags)
232#define ClearPagePrivate(page) clear_bit(PG_private, &(page)->flags)
233#define PagePrivate(page) test_bit(PG_private, &(page)->flags)
234#define __SetPagePrivate(page) __set_bit(PG_private, &(page)->flags)
235#define __ClearPagePrivate(page) __clear_bit(PG_private, &(page)->flags)
236
237#define PageWriteback(page) test_bit(PG_writeback, &(page)->flags)
238#define SetPageWriteback(page) \
239 do { \
240 if (!test_and_set_bit(PG_writeback, \
241 &(page)->flags)) \
242 inc_page_state(nr_writeback); \
243 } while (0)
244#define TestSetPageWriteback(page) \
245 ({ \
246 int ret; \
247 ret = test_and_set_bit(PG_writeback, \
248 &(page)->flags); \
249 if (!ret) \
250 inc_page_state(nr_writeback); \
251 ret; \
252 })
253#define ClearPageWriteback(page) \
254 do { \
255 if (test_and_clear_bit(PG_writeback, \
256 &(page)->flags)) \
257 dec_page_state(nr_writeback); \
258 } while (0)
259#define TestClearPageWriteback(page) \
260 ({ \
261 int ret; \
262 ret = test_and_clear_bit(PG_writeback, \
263 &(page)->flags); \
264 if (ret) \
265 dec_page_state(nr_writeback); \
266 ret; \
267 })
268
269#define PageNosave(page) test_bit(PG_nosave, &(page)->flags)
270#define SetPageNosave(page) set_bit(PG_nosave, &(page)->flags)
271#define TestSetPageNosave(page) test_and_set_bit(PG_nosave, &(page)->flags)
272#define ClearPageNosave(page) clear_bit(PG_nosave, &(page)->flags)
273#define TestClearPageNosave(page) test_and_clear_bit(PG_nosave, &(page)->flags)
274
275#define PageNosaveFree(page) test_bit(PG_nosave_free, &(page)->flags)
276#define SetPageNosaveFree(page) set_bit(PG_nosave_free, &(page)->flags)
277#define ClearPageNosaveFree(page) clear_bit(PG_nosave_free, &(page)->flags)
278
279#define PageMappedToDisk(page) test_bit(PG_mappedtodisk, &(page)->flags)
280#define SetPageMappedToDisk(page) set_bit(PG_mappedtodisk, &(page)->flags)
281#define ClearPageMappedToDisk(page) clear_bit(PG_mappedtodisk, &(page)->flags)
282
283#define PageReclaim(page) test_bit(PG_reclaim, &(page)->flags)
284#define SetPageReclaim(page) set_bit(PG_reclaim, &(page)->flags)
285#define ClearPageReclaim(page) clear_bit(PG_reclaim, &(page)->flags)
286#define TestClearPageReclaim(page) test_and_clear_bit(PG_reclaim, &(page)->flags)
287
288#ifdef CONFIG_HUGETLB_PAGE
289#define PageCompound(page) test_bit(PG_compound, &(page)->flags)
290#else
291#define PageCompound(page) 0
292#endif
293#define SetPageCompound(page) set_bit(PG_compound, &(page)->flags)
294#define ClearPageCompound(page) clear_bit(PG_compound, &(page)->flags)
295
296#ifdef CONFIG_SWAP
297#define PageSwapCache(page) test_bit(PG_swapcache, &(page)->flags)
298#define SetPageSwapCache(page) set_bit(PG_swapcache, &(page)->flags)
299#define ClearPageSwapCache(page) clear_bit(PG_swapcache, &(page)->flags)
300#else
301#define PageSwapCache(page) 0
302#endif
303
304#define PageUncached(page) test_bit(PG_uncached, &(page)->flags)
305#define SetPageUncached(page) set_bit(PG_uncached, &(page)->flags)
306#define ClearPageUncached(page) clear_bit(PG_uncached, &(page)->flags)
307
308struct page; /* forward declaration */
309
310int test_clear_page_dirty(struct page *page);
311int test_clear_page_writeback(struct page *page);
312int test_set_page_writeback(struct page *page);
313
314static inline void clear_page_dirty(struct page *page)
315{
316 test_clear_page_dirty(page);
317}
318
319static inline void set_page_writeback(struct page *page)
320{
321 test_set_page_writeback(page);
322}
323
324#endif /* PAGE_FLAGS_H */