[S390] Fix gcc warning about unused return values.
[linux-2.6] / include / linux / page-flags.h
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/types.h>
9
10 /*
11  * Various page->flags bits:
12  *
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)...
15  *
16  * The PG_private bitflag is set if page->private contains a valid value.
17  *
18  * During disk I/O, PG_locked is used. This bit is set before I/O and
19  * reset when I/O completes. page_waitqueue(page) is a wait queue of all tasks
20  * waiting for the I/O on this page to complete.
21  *
22  * PG_uptodate tells whether the page's contents is valid.  When a read
23  * completes, the page becomes uptodate, unless a disk I/O error happened.
24  *
25  * For choosing which pages to swap out, inode pages carry a PG_referenced bit,
26  * which is set any time the system accesses that page through the (mapping,
27  * index) hash table.  This referenced bit, together with the referenced bit
28  * in the page tables, is used to manipulate page->age and move the page across
29  * the active, inactive_dirty and inactive_clean lists.
30  *
31  * Note that the referenced bit, the page->lru list_head and the active,
32  * inactive_dirty and inactive_clean lists are protected by the
33  * zone->lru_lock, and *NOT* by the usual PG_locked bit!
34  *
35  * PG_error is set to indicate that an I/O error occurred on this page.
36  *
37  * PG_arch_1 is an architecture specific page state bit.  The generic code
38  * guarantees that this bit is cleared for a page when it first is entered into
39  * the page cache.
40  *
41  * PG_highmem pages are not permanently mapped into the kernel virtual address
42  * space, they need to be kmapped separately for doing IO on the pages.  The
43  * struct page (these bits with information) are always mapped into kernel
44  * address space...
45  */
46
47 /*
48  * Don't use the *_dontuse flags.  Use the macros.  Otherwise you'll break
49  * locked- and dirty-page accounting.
50  *
51  * The page flags field is split into two parts, the main flags area
52  * which extends from the low bits upwards, and the fields area which
53  * extends from the high bits downwards.
54  *
55  *  | FIELD | ... | FLAGS |
56  *  N-1     ^             0
57  *          (N-FLAGS_RESERVED)
58  *
59  * The fields area is reserved for fields mapping zone, node and SPARSEMEM
60  * section.  The boundry between these two areas is defined by
61  * FLAGS_RESERVED which defines the width of the fields section
62  * (see linux/mmzone.h).  New flags must _not_ overlap with this area.
63  */
64 #define PG_locked                0      /* Page is locked. Don't touch. */
65 #define PG_error                 1
66 #define PG_referenced            2
67 #define PG_uptodate              3
68
69 #define PG_dirty                 4
70 #define PG_lru                   5
71 #define PG_active                6
72 #define PG_slab                  7      /* slab debug (Suparna wants this) */
73
74 #define PG_checked               8      /* kill me in 2.5.<early>. */
75 #define PG_arch_1                9
76 #define PG_reserved             10
77 #define PG_private              11      /* Has something at ->private */
78
79 #define PG_writeback            12      /* Page is under writeback */
80 #define PG_nosave               13      /* Used for system suspend/resume */
81 #define PG_compound             14      /* Part of a compound page */
82 #define PG_swapcache            15      /* Swap page: swp_entry_t in private */
83
84 #define PG_mappedtodisk         16      /* Has blocks allocated on-disk */
85 #define PG_reclaim              17      /* To be reclaimed asap */
86 #define PG_nosave_free          18      /* Free, should not be written */
87 #define PG_buddy                19      /* Page is free, on buddy lists */
88
89
90 #if (BITS_PER_LONG > 32)
91 /*
92  * 64-bit-only flags build down from bit 31
93  *
94  * 32 bit  -------------------------------| FIELDS |       FLAGS         |
95  * 64 bit  |           FIELDS             | ??????         FLAGS         |
96  *         63                            32                              0
97  */
98 #define PG_uncached             31      /* Page has been mapped as uncached */
99 #endif
100
101 /*
102  * Manipulation of page state flags
103  */
104 #define PageLocked(page)                \
105                 test_bit(PG_locked, &(page)->flags)
106 #define SetPageLocked(page)             \
107                 set_bit(PG_locked, &(page)->flags)
108 #define TestSetPageLocked(page)         \
109                 test_and_set_bit(PG_locked, &(page)->flags)
110 #define ClearPageLocked(page)           \
111                 clear_bit(PG_locked, &(page)->flags)
112 #define TestClearPageLocked(page)       \
113                 test_and_clear_bit(PG_locked, &(page)->flags)
114
115 #define PageError(page)         test_bit(PG_error, &(page)->flags)
116 #define SetPageError(page)      set_bit(PG_error, &(page)->flags)
117 #define ClearPageError(page)    clear_bit(PG_error, &(page)->flags)
118
119 #define PageReferenced(page)    test_bit(PG_referenced, &(page)->flags)
120 #define SetPageReferenced(page) set_bit(PG_referenced, &(page)->flags)
121 #define ClearPageReferenced(page)       clear_bit(PG_referenced, &(page)->flags)
122 #define TestClearPageReferenced(page) test_and_clear_bit(PG_referenced, &(page)->flags)
123
124 #define PageUptodate(page)      test_bit(PG_uptodate, &(page)->flags)
125 #ifdef CONFIG_S390
126 #define SetPageUptodate(_page) \
127         do {                                                                  \
128                 struct page *__page = (_page);                                \
129                 if (!test_and_set_bit(PG_uptodate, &__page->flags))           \
130                         page_test_and_clear_dirty(_page);                     \
131         } while (0)
132 #else
133 #define SetPageUptodate(page)   set_bit(PG_uptodate, &(page)->flags)
134 #endif
135 #define ClearPageUptodate(page) clear_bit(PG_uptodate, &(page)->flags)
136
137 #define PageDirty(page)         test_bit(PG_dirty, &(page)->flags)
138 #define SetPageDirty(page)      set_bit(PG_dirty, &(page)->flags)
139 #define TestSetPageDirty(page)  test_and_set_bit(PG_dirty, &(page)->flags)
140 #define ClearPageDirty(page)    clear_bit(PG_dirty, &(page)->flags)
141 #define __ClearPageDirty(page)  __clear_bit(PG_dirty, &(page)->flags)
142 #define TestClearPageDirty(page) test_and_clear_bit(PG_dirty, &(page)->flags)
143
144 #define PageLRU(page)           test_bit(PG_lru, &(page)->flags)
145 #define SetPageLRU(page)        set_bit(PG_lru, &(page)->flags)
146 #define ClearPageLRU(page)      clear_bit(PG_lru, &(page)->flags)
147 #define __ClearPageLRU(page)    __clear_bit(PG_lru, &(page)->flags)
148
149 #define PageActive(page)        test_bit(PG_active, &(page)->flags)
150 #define SetPageActive(page)     set_bit(PG_active, &(page)->flags)
151 #define ClearPageActive(page)   clear_bit(PG_active, &(page)->flags)
152 #define __ClearPageActive(page) __clear_bit(PG_active, &(page)->flags)
153
154 #define PageSlab(page)          test_bit(PG_slab, &(page)->flags)
155 #define __SetPageSlab(page)     __set_bit(PG_slab, &(page)->flags)
156 #define __ClearPageSlab(page)   __clear_bit(PG_slab, &(page)->flags)
157
158 #ifdef CONFIG_HIGHMEM
159 #define PageHighMem(page)       is_highmem(page_zone(page))
160 #else
161 #define PageHighMem(page)       0 /* needed to optimize away at compile time */
162 #endif
163
164 #define PageChecked(page)       test_bit(PG_checked, &(page)->flags)
165 #define SetPageChecked(page)    set_bit(PG_checked, &(page)->flags)
166 #define ClearPageChecked(page)  clear_bit(PG_checked, &(page)->flags)
167
168 #define PageReserved(page)      test_bit(PG_reserved, &(page)->flags)
169 #define SetPageReserved(page)   set_bit(PG_reserved, &(page)->flags)
170 #define ClearPageReserved(page) clear_bit(PG_reserved, &(page)->flags)
171 #define __ClearPageReserved(page)       __clear_bit(PG_reserved, &(page)->flags)
172
173 #define SetPagePrivate(page)    set_bit(PG_private, &(page)->flags)
174 #define ClearPagePrivate(page)  clear_bit(PG_private, &(page)->flags)
175 #define PagePrivate(page)       test_bit(PG_private, &(page)->flags)
176 #define __SetPagePrivate(page)  __set_bit(PG_private, &(page)->flags)
177 #define __ClearPagePrivate(page) __clear_bit(PG_private, &(page)->flags)
178
179 #define PageWriteback(page)     test_bit(PG_writeback, &(page)->flags)
180 #define SetPageWriteback(page)                                          \
181         do {                                                            \
182                 if (!test_and_set_bit(PG_writeback,                     \
183                                 &(page)->flags))                        \
184                         inc_zone_page_state(page, NR_WRITEBACK);        \
185         } while (0)
186 #define TestSetPageWriteback(page)                                      \
187         ({                                                              \
188                 int ret;                                                \
189                 ret = test_and_set_bit(PG_writeback,                    \
190                                         &(page)->flags);                \
191                 if (!ret)                                               \
192                         inc_zone_page_state(page, NR_WRITEBACK);        \
193                 ret;                                                    \
194         })
195 #define ClearPageWriteback(page)                                        \
196         do {                                                            \
197                 if (test_and_clear_bit(PG_writeback,                    \
198                                 &(page)->flags))                        \
199                         dec_zone_page_state(page, NR_WRITEBACK);        \
200         } while (0)
201 #define TestClearPageWriteback(page)                                    \
202         ({                                                              \
203                 int ret;                                                \
204                 ret = test_and_clear_bit(PG_writeback,                  \
205                                 &(page)->flags);                        \
206                 if (ret)                                                \
207                         dec_zone_page_state(page, NR_WRITEBACK);        \
208                 ret;                                                    \
209         })
210
211 #define PageNosave(page)        test_bit(PG_nosave, &(page)->flags)
212 #define SetPageNosave(page)     set_bit(PG_nosave, &(page)->flags)
213 #define TestSetPageNosave(page) test_and_set_bit(PG_nosave, &(page)->flags)
214 #define ClearPageNosave(page)           clear_bit(PG_nosave, &(page)->flags)
215 #define TestClearPageNosave(page)       test_and_clear_bit(PG_nosave, &(page)->flags)
216
217 #define PageNosaveFree(page)    test_bit(PG_nosave_free, &(page)->flags)
218 #define SetPageNosaveFree(page) set_bit(PG_nosave_free, &(page)->flags)
219 #define ClearPageNosaveFree(page)               clear_bit(PG_nosave_free, &(page)->flags)
220
221 #define PageBuddy(page)         test_bit(PG_buddy, &(page)->flags)
222 #define __SetPageBuddy(page)    __set_bit(PG_buddy, &(page)->flags)
223 #define __ClearPageBuddy(page)  __clear_bit(PG_buddy, &(page)->flags)
224
225 #define PageMappedToDisk(page)  test_bit(PG_mappedtodisk, &(page)->flags)
226 #define SetPageMappedToDisk(page) set_bit(PG_mappedtodisk, &(page)->flags)
227 #define ClearPageMappedToDisk(page) clear_bit(PG_mappedtodisk, &(page)->flags)
228
229 #define PageReclaim(page)       test_bit(PG_reclaim, &(page)->flags)
230 #define SetPageReclaim(page)    set_bit(PG_reclaim, &(page)->flags)
231 #define ClearPageReclaim(page)  clear_bit(PG_reclaim, &(page)->flags)
232 #define TestClearPageReclaim(page) test_and_clear_bit(PG_reclaim, &(page)->flags)
233
234 #define PageCompound(page)      test_bit(PG_compound, &(page)->flags)
235 #define __SetPageCompound(page) __set_bit(PG_compound, &(page)->flags)
236 #define __ClearPageCompound(page) __clear_bit(PG_compound, &(page)->flags)
237
238 #ifdef CONFIG_SWAP
239 #define PageSwapCache(page)     test_bit(PG_swapcache, &(page)->flags)
240 #define SetPageSwapCache(page)  set_bit(PG_swapcache, &(page)->flags)
241 #define ClearPageSwapCache(page) clear_bit(PG_swapcache, &(page)->flags)
242 #else
243 #define PageSwapCache(page)     0
244 #endif
245
246 #define PageUncached(page)      test_bit(PG_uncached, &(page)->flags)
247 #define SetPageUncached(page)   set_bit(PG_uncached, &(page)->flags)
248 #define ClearPageUncached(page) clear_bit(PG_uncached, &(page)->flags)
249
250 struct page;    /* forward declaration */
251
252 int test_clear_page_dirty(struct page *page);
253 int test_clear_page_writeback(struct page *page);
254 int test_set_page_writeback(struct page *page);
255
256 static inline void clear_page_dirty(struct page *page)
257 {
258         test_clear_page_dirty(page);
259 }
260
261 static inline void set_page_writeback(struct page *page)
262 {
263         test_set_page_writeback(page);
264 }
265
266 #endif  /* PAGE_FLAGS_H */