[SK_BUFF]: Use the helpers to get the layer header pointer
[linux-2.6/mini2440.git] / include / linux / page-flags.h
blob9cd0d0eaf5239a3276aecb6b2a83e7f399acda27
1 /*
2 * Macros for manipulating and testing page->flags
3 */
5 #ifndef PAGE_FLAGS_H
6 #define PAGE_FLAGS_H
8 #include <linux/types.h>
11 * Various page->flags bits:
13 * PG_reserved is set for special pages, which can never be swapped out. Some
14 * of them might not even exist (eg empty_bad_page)...
16 * The PG_private bitflag is set on pagecache pages if they contain filesystem
17 * specific data (which is normally at page->private). It can be used by
18 * private allocations for its own usage.
20 * During initiation of disk I/O, PG_locked is set. This bit is set before I/O
21 * and cleared when writeback _starts_ or when read _completes_. PG_writeback
22 * is set before writeback starts and cleared when it finishes.
24 * PG_locked also pins a page in pagecache, and blocks truncation of the file
25 * while it is held.
27 * page_waitqueue(page) is a wait queue of all tasks waiting for the page
28 * to become unlocked.
30 * PG_uptodate tells whether the page's contents is valid. When a read
31 * completes, the page becomes uptodate, unless a disk I/O error happened.
33 * PG_referenced, PG_reclaim are used for page reclaim for anonymous and
34 * file-backed pagecache (see mm/vmscan.c).
36 * PG_error is set to indicate that an I/O error occurred on this page.
38 * PG_arch_1 is an architecture specific page state bit. The generic code
39 * guarantees that this bit is cleared for a page when it first is entered into
40 * the page cache.
42 * PG_highmem pages are not permanently mapped into the kernel virtual address
43 * space, they need to be kmapped separately for doing IO on the pages. The
44 * struct page (these bits with information) are always mapped into kernel
45 * address space...
47 * PG_buddy is set to indicate that the page is free and in the buddy system
48 * (see mm/page_alloc.c).
53 * Don't use the *_dontuse flags. Use the macros. Otherwise you'll break
54 * locked- and dirty-page accounting.
56 * The page flags field is split into two parts, the main flags area
57 * which extends from the low bits upwards, and the fields area which
58 * extends from the high bits downwards.
60 * | FIELD | ... | FLAGS |
61 * N-1 ^ 0
62 * (N-FLAGS_RESERVED)
64 * The fields area is reserved for fields mapping zone, node and SPARSEMEM
65 * section. The boundry between these two areas is defined by
66 * FLAGS_RESERVED which defines the width of the fields section
67 * (see linux/mmzone.h). New flags must _not_ overlap with this area.
69 #define PG_locked 0 /* Page is locked. Don't touch. */
70 #define PG_error 1
71 #define PG_referenced 2
72 #define PG_uptodate 3
74 #define PG_dirty 4
75 #define PG_lru 5
76 #define PG_active 6
77 #define PG_slab 7 /* slab debug (Suparna wants this) */
79 #define PG_owner_priv_1 8 /* Owner use. If pagecache, fs may use*/
80 #define PG_arch_1 9
81 #define PG_reserved 10
82 #define PG_private 11 /* If pagecache, has fs-private data */
84 #define PG_writeback 12 /* Page is under writeback */
85 #define PG_nosave 13 /* Used for system suspend/resume */
86 #define PG_compound 14 /* Part of a compound page */
87 #define PG_swapcache 15 /* Swap page: swp_entry_t in private */
89 #define PG_mappedtodisk 16 /* Has blocks allocated on-disk */
90 #define PG_reclaim 17 /* To be reclaimed asap */
91 #define PG_nosave_free 18 /* Used for system suspend/resume */
92 #define PG_buddy 19 /* Page is free, on buddy lists */
94 /* PG_owner_priv_1 users should have descriptive aliases */
95 #define PG_checked PG_owner_priv_1 /* Used by some filesystems */
97 #if (BITS_PER_LONG > 32)
99 * 64-bit-only flags build down from bit 31
101 * 32 bit -------------------------------| FIELDS | FLAGS |
102 * 64 bit | FIELDS | ?????? FLAGS |
103 * 63 32 0
105 #define PG_uncached 31 /* Page has been mapped as uncached */
106 #endif
109 * Manipulation of page state flags
111 #define PageLocked(page) \
112 test_bit(PG_locked, &(page)->flags)
113 #define SetPageLocked(page) \
114 set_bit(PG_locked, &(page)->flags)
115 #define TestSetPageLocked(page) \
116 test_and_set_bit(PG_locked, &(page)->flags)
117 #define ClearPageLocked(page) \
118 clear_bit(PG_locked, &(page)->flags)
119 #define TestClearPageLocked(page) \
120 test_and_clear_bit(PG_locked, &(page)->flags)
122 #define PageError(page) test_bit(PG_error, &(page)->flags)
123 #define SetPageError(page) set_bit(PG_error, &(page)->flags)
124 #define ClearPageError(page) clear_bit(PG_error, &(page)->flags)
126 #define PageReferenced(page) test_bit(PG_referenced, &(page)->flags)
127 #define SetPageReferenced(page) set_bit(PG_referenced, &(page)->flags)
128 #define ClearPageReferenced(page) clear_bit(PG_referenced, &(page)->flags)
129 #define TestClearPageReferenced(page) test_and_clear_bit(PG_referenced, &(page)->flags)
131 #define PageUptodate(page) test_bit(PG_uptodate, &(page)->flags)
132 #ifdef CONFIG_S390
133 static inline void SetPageUptodate(struct page *page)
135 if (!test_and_set_bit(PG_uptodate, &page->flags))
136 page_test_and_clear_dirty(page);
138 #else
139 #define SetPageUptodate(page) set_bit(PG_uptodate, &(page)->flags)
140 #endif
141 #define ClearPageUptodate(page) clear_bit(PG_uptodate, &(page)->flags)
143 #define PageDirty(page) test_bit(PG_dirty, &(page)->flags)
144 #define SetPageDirty(page) set_bit(PG_dirty, &(page)->flags)
145 #define TestSetPageDirty(page) test_and_set_bit(PG_dirty, &(page)->flags)
146 #define ClearPageDirty(page) clear_bit(PG_dirty, &(page)->flags)
147 #define __ClearPageDirty(page) __clear_bit(PG_dirty, &(page)->flags)
148 #define TestClearPageDirty(page) test_and_clear_bit(PG_dirty, &(page)->flags)
150 #define PageLRU(page) test_bit(PG_lru, &(page)->flags)
151 #define SetPageLRU(page) set_bit(PG_lru, &(page)->flags)
152 #define ClearPageLRU(page) clear_bit(PG_lru, &(page)->flags)
153 #define __ClearPageLRU(page) __clear_bit(PG_lru, &(page)->flags)
155 #define PageActive(page) test_bit(PG_active, &(page)->flags)
156 #define SetPageActive(page) set_bit(PG_active, &(page)->flags)
157 #define ClearPageActive(page) clear_bit(PG_active, &(page)->flags)
158 #define __ClearPageActive(page) __clear_bit(PG_active, &(page)->flags)
160 #define PageSlab(page) test_bit(PG_slab, &(page)->flags)
161 #define __SetPageSlab(page) __set_bit(PG_slab, &(page)->flags)
162 #define __ClearPageSlab(page) __clear_bit(PG_slab, &(page)->flags)
164 #ifdef CONFIG_HIGHMEM
165 #define PageHighMem(page) is_highmem(page_zone(page))
166 #else
167 #define PageHighMem(page) 0 /* needed to optimize away at compile time */
168 #endif
170 #define PageChecked(page) test_bit(PG_checked, &(page)->flags)
171 #define SetPageChecked(page) set_bit(PG_checked, &(page)->flags)
172 #define ClearPageChecked(page) clear_bit(PG_checked, &(page)->flags)
174 #define PageReserved(page) test_bit(PG_reserved, &(page)->flags)
175 #define SetPageReserved(page) set_bit(PG_reserved, &(page)->flags)
176 #define ClearPageReserved(page) clear_bit(PG_reserved, &(page)->flags)
177 #define __ClearPageReserved(page) __clear_bit(PG_reserved, &(page)->flags)
179 #define SetPagePrivate(page) set_bit(PG_private, &(page)->flags)
180 #define ClearPagePrivate(page) clear_bit(PG_private, &(page)->flags)
181 #define PagePrivate(page) test_bit(PG_private, &(page)->flags)
182 #define __SetPagePrivate(page) __set_bit(PG_private, &(page)->flags)
183 #define __ClearPagePrivate(page) __clear_bit(PG_private, &(page)->flags)
185 #define PageWriteback(page) test_bit(PG_writeback, &(page)->flags)
186 #define SetPageWriteback(page) \
187 do { \
188 if (!test_and_set_bit(PG_writeback, \
189 &(page)->flags)) \
190 inc_zone_page_state(page, NR_WRITEBACK); \
191 } while (0)
192 #define TestSetPageWriteback(page) \
193 ({ \
194 int ret; \
195 ret = test_and_set_bit(PG_writeback, \
196 &(page)->flags); \
197 if (!ret) \
198 inc_zone_page_state(page, NR_WRITEBACK); \
199 ret; \
201 #define ClearPageWriteback(page) \
202 do { \
203 if (test_and_clear_bit(PG_writeback, \
204 &(page)->flags)) \
205 dec_zone_page_state(page, NR_WRITEBACK); \
206 } while (0)
207 #define TestClearPageWriteback(page) \
208 ({ \
209 int ret; \
210 ret = test_and_clear_bit(PG_writeback, \
211 &(page)->flags); \
212 if (ret) \
213 dec_zone_page_state(page, NR_WRITEBACK); \
214 ret; \
217 #define PageNosave(page) test_bit(PG_nosave, &(page)->flags)
218 #define SetPageNosave(page) set_bit(PG_nosave, &(page)->flags)
219 #define TestSetPageNosave(page) test_and_set_bit(PG_nosave, &(page)->flags)
220 #define ClearPageNosave(page) clear_bit(PG_nosave, &(page)->flags)
221 #define TestClearPageNosave(page) test_and_clear_bit(PG_nosave, &(page)->flags)
223 #define PageNosaveFree(page) test_bit(PG_nosave_free, &(page)->flags)
224 #define SetPageNosaveFree(page) set_bit(PG_nosave_free, &(page)->flags)
225 #define ClearPageNosaveFree(page) clear_bit(PG_nosave_free, &(page)->flags)
227 #define PageBuddy(page) test_bit(PG_buddy, &(page)->flags)
228 #define __SetPageBuddy(page) __set_bit(PG_buddy, &(page)->flags)
229 #define __ClearPageBuddy(page) __clear_bit(PG_buddy, &(page)->flags)
231 #define PageMappedToDisk(page) test_bit(PG_mappedtodisk, &(page)->flags)
232 #define SetPageMappedToDisk(page) set_bit(PG_mappedtodisk, &(page)->flags)
233 #define ClearPageMappedToDisk(page) clear_bit(PG_mappedtodisk, &(page)->flags)
235 #define PageReclaim(page) test_bit(PG_reclaim, &(page)->flags)
236 #define SetPageReclaim(page) set_bit(PG_reclaim, &(page)->flags)
237 #define ClearPageReclaim(page) clear_bit(PG_reclaim, &(page)->flags)
238 #define TestClearPageReclaim(page) test_and_clear_bit(PG_reclaim, &(page)->flags)
240 #define PageCompound(page) test_bit(PG_compound, &(page)->flags)
241 #define __SetPageCompound(page) __set_bit(PG_compound, &(page)->flags)
242 #define __ClearPageCompound(page) __clear_bit(PG_compound, &(page)->flags)
244 #ifdef CONFIG_SWAP
245 #define PageSwapCache(page) test_bit(PG_swapcache, &(page)->flags)
246 #define SetPageSwapCache(page) set_bit(PG_swapcache, &(page)->flags)
247 #define ClearPageSwapCache(page) clear_bit(PG_swapcache, &(page)->flags)
248 #else
249 #define PageSwapCache(page) 0
250 #endif
252 #define PageUncached(page) test_bit(PG_uncached, &(page)->flags)
253 #define SetPageUncached(page) set_bit(PG_uncached, &(page)->flags)
254 #define ClearPageUncached(page) clear_bit(PG_uncached, &(page)->flags)
256 struct page; /* forward declaration */
258 extern void cancel_dirty_page(struct page *page, unsigned int account_size);
260 int test_clear_page_writeback(struct page *page);
261 int test_set_page_writeback(struct page *page);
263 static inline void set_page_writeback(struct page *page)
265 test_set_page_writeback(page);
268 #endif /* PAGE_FLAGS_H */