Rev 6082 | Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
5270 | serge | 1 | #ifndef __LINUX_GFP_H |
2 | #define __LINUX_GFP_H |
||
3 | |||
4 | #include |
||
5 | #include |
||
6 | #include |
||
7 | #include |
||
8 | |||
9 | struct vm_area_struct; |
||
10 | |||
11 | /* Plain integer GFP bitmasks. Do not use this directly. */ |
||
12 | #define ___GFP_DMA 0x01u |
||
13 | #define ___GFP_HIGHMEM 0x02u |
||
14 | #define ___GFP_DMA32 0x04u |
||
15 | #define ___GFP_MOVABLE 0x08u |
||
16 | #define ___GFP_WAIT 0x10u |
||
17 | #define ___GFP_HIGH 0x20u |
||
18 | #define ___GFP_IO 0x40u |
||
19 | #define ___GFP_FS 0x80u |
||
20 | #define ___GFP_COLD 0x100u |
||
21 | #define ___GFP_NOWARN 0x200u |
||
22 | #define ___GFP_REPEAT 0x400u |
||
23 | #define ___GFP_NOFAIL 0x800u |
||
24 | #define ___GFP_NORETRY 0x1000u |
||
25 | #define ___GFP_MEMALLOC 0x2000u |
||
26 | #define ___GFP_COMP 0x4000u |
||
27 | #define ___GFP_ZERO 0x8000u |
||
28 | #define ___GFP_NOMEMALLOC 0x10000u |
||
29 | #define ___GFP_HARDWALL 0x20000u |
||
30 | #define ___GFP_THISNODE 0x40000u |
||
31 | #define ___GFP_RECLAIMABLE 0x80000u |
||
32 | #define ___GFP_NOTRACK 0x200000u |
||
33 | #define ___GFP_NO_KSWAPD 0x400000u |
||
34 | #define ___GFP_OTHER_NODE 0x800000u |
||
35 | #define ___GFP_WRITE 0x1000000u |
||
36 | /* If the above are modified, __GFP_BITS_SHIFT may need updating */ |
||
37 | |||
38 | /* |
||
39 | * GFP bitmasks.. |
||
40 | * |
||
41 | * Zone modifiers (see linux/mmzone.h - low three bits) |
||
42 | * |
||
43 | * Do not put any conditional on these. If necessary modify the definitions |
||
44 | * without the underscores and use them consistently. The definitions here may |
||
45 | * be used in bit comparisons. |
||
46 | */ |
||
47 | #define __GFP_DMA ((__force gfp_t)___GFP_DMA) |
||
48 | #define __GFP_HIGHMEM ((__force gfp_t)___GFP_HIGHMEM) |
||
49 | #define __GFP_DMA32 ((__force gfp_t)___GFP_DMA32) |
||
50 | #define __GFP_MOVABLE ((__force gfp_t)___GFP_MOVABLE) /* Page is movable */ |
||
51 | #define GFP_ZONEMASK (__GFP_DMA|__GFP_HIGHMEM|__GFP_DMA32|__GFP_MOVABLE) |
||
52 | /* |
||
53 | * Action modifiers - doesn't change the zoning |
||
54 | * |
||
55 | * __GFP_REPEAT: Try hard to allocate the memory, but the allocation attempt |
||
56 | * _might_ fail. This depends upon the particular VM implementation. |
||
57 | * |
||
58 | * __GFP_NOFAIL: The VM implementation _must_ retry infinitely: the caller |
||
59 | * cannot handle allocation failures. This modifier is deprecated and no new |
||
60 | * users should be added. |
||
61 | * |
||
62 | * __GFP_NORETRY: The VM implementation must not retry indefinitely. |
||
63 | * |
||
64 | * __GFP_MOVABLE: Flag that this page will be movable by the page migration |
||
65 | * mechanism or reclaimed |
||
66 | */ |
||
67 | #define __GFP_WAIT ((__force gfp_t)___GFP_WAIT) /* Can wait and reschedule? */ |
||
68 | #define __GFP_HIGH ((__force gfp_t)___GFP_HIGH) /* Should access emergency pools? */ |
||
69 | #define __GFP_IO ((__force gfp_t)___GFP_IO) /* Can start physical IO? */ |
||
70 | #define __GFP_FS ((__force gfp_t)___GFP_FS) /* Can call down to low-level FS? */ |
||
71 | #define __GFP_COLD ((__force gfp_t)___GFP_COLD) /* Cache-cold page required */ |
||
72 | #define __GFP_NOWARN ((__force gfp_t)___GFP_NOWARN) /* Suppress page allocation failure warning */ |
||
73 | #define __GFP_REPEAT ((__force gfp_t)___GFP_REPEAT) /* See above */ |
||
74 | #define __GFP_NOFAIL ((__force gfp_t)___GFP_NOFAIL) /* See above */ |
||
75 | #define __GFP_NORETRY ((__force gfp_t)___GFP_NORETRY) /* See above */ |
||
76 | #define __GFP_MEMALLOC ((__force gfp_t)___GFP_MEMALLOC)/* Allow access to emergency reserves */ |
||
77 | #define __GFP_COMP ((__force gfp_t)___GFP_COMP) /* Add compound page metadata */ |
||
78 | #define __GFP_ZERO ((__force gfp_t)___GFP_ZERO) /* Return zeroed page on success */ |
||
79 | #define __GFP_NOMEMALLOC ((__force gfp_t)___GFP_NOMEMALLOC) /* Don't use emergency reserves. |
||
80 | * This takes precedence over the |
||
81 | * __GFP_MEMALLOC flag if both are |
||
82 | * set |
||
83 | */ |
||
84 | #define __GFP_HARDWALL ((__force gfp_t)___GFP_HARDWALL) /* Enforce hardwall cpuset memory allocs */ |
||
85 | #define __GFP_THISNODE ((__force gfp_t)___GFP_THISNODE)/* No fallback, no policies */ |
||
86 | #define __GFP_RECLAIMABLE ((__force gfp_t)___GFP_RECLAIMABLE) /* Page is reclaimable */ |
||
87 | #define __GFP_NOTRACK ((__force gfp_t)___GFP_NOTRACK) /* Don't track with kmemcheck */ |
||
88 | |||
89 | #define __GFP_NO_KSWAPD ((__force gfp_t)___GFP_NO_KSWAPD) |
||
90 | #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */ |
||
91 | #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */ |
||
92 | |||
93 | /* |
||
94 | * This may seem redundant, but it's a way of annotating false positives vs. |
||
95 | * allocations that simply cannot be supported (e.g. page tables). |
||
96 | */ |
||
97 | #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK) |
||
98 | |||
99 | #define __GFP_BITS_SHIFT 25 /* Room for N __GFP_FOO bits */ |
||
100 | #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1)) |
||
101 | |||
102 | /* This equals 0, but use constants in case they ever change */ |
||
103 | #define GFP_NOWAIT (GFP_ATOMIC & ~__GFP_HIGH) |
||
104 | /* GFP_ATOMIC means both !wait (__GFP_WAIT not set) and use emergency pool */ |
||
105 | #define GFP_ATOMIC (__GFP_HIGH) |
||
106 | #define GFP_NOIO (__GFP_WAIT) |
||
107 | #define GFP_NOFS (__GFP_WAIT | __GFP_IO) |
||
108 | #define GFP_KERNEL (__GFP_WAIT | __GFP_IO | __GFP_FS) |
||
109 | #define GFP_TEMPORARY (__GFP_WAIT | __GFP_IO | __GFP_FS | \ |
||
110 | __GFP_RECLAIMABLE) |
||
111 | #define GFP_USER (__GFP_WAIT | __GFP_IO | __GFP_FS | __GFP_HARDWALL) |
||
112 | #define GFP_HIGHUSER (GFP_USER | __GFP_HIGHMEM) |
||
113 | #define GFP_HIGHUSER_MOVABLE (GFP_HIGHUSER | __GFP_MOVABLE) |
||
114 | #define GFP_IOFS (__GFP_IO | __GFP_FS) |
||
115 | #define GFP_TRANSHUGE (GFP_HIGHUSER_MOVABLE | __GFP_COMP | \ |
||
116 | __GFP_NOMEMALLOC | __GFP_NORETRY | __GFP_NOWARN | \ |
||
117 | __GFP_NO_KSWAPD) |
||
118 | |||
119 | /* |
||
120 | * GFP_THISNODE does not perform any reclaim, you most likely want to |
||
121 | * use __GFP_THISNODE to allocate from a given node without fallback! |
||
122 | */ |
||
123 | #ifdef CONFIG_NUMA |
||
124 | #define GFP_THISNODE (__GFP_THISNODE | __GFP_NOWARN | __GFP_NORETRY) |
||
125 | #else |
||
126 | #define GFP_THISNODE ((__force gfp_t)0) |
||
127 | #endif |
||
128 | |||
129 | /* This mask makes up all the page movable related flags */ |
||
130 | #define GFP_MOVABLE_MASK (__GFP_RECLAIMABLE|__GFP_MOVABLE) |
||
131 | |||
132 | /* Control page allocator reclaim behavior */ |
||
133 | #define GFP_RECLAIM_MASK (__GFP_WAIT|__GFP_HIGH|__GFP_IO|__GFP_FS|\ |
||
134 | __GFP_NOWARN|__GFP_REPEAT|__GFP_NOFAIL|\ |
||
135 | __GFP_NORETRY|__GFP_MEMALLOC|__GFP_NOMEMALLOC) |
||
136 | |||
137 | /* Control slab gfp mask during early boot */ |
||
138 | #define GFP_BOOT_MASK (__GFP_BITS_MASK & ~(__GFP_WAIT|__GFP_IO|__GFP_FS)) |
||
139 | |||
140 | /* Control allocation constraints */ |
||
141 | #define GFP_CONSTRAINT_MASK (__GFP_HARDWALL|__GFP_THISNODE) |
||
142 | |||
143 | /* Do not use these with a slab allocator */ |
||
144 | #define GFP_SLAB_BUG_MASK (__GFP_DMA32|__GFP_HIGHMEM|~__GFP_BITS_MASK) |
||
145 | |||
146 | /* Flag - indicates that the buffer will be suitable for DMA. Ignored on some |
||
147 | platforms, used as appropriate on others */ |
||
148 | |||
149 | #define GFP_DMA __GFP_DMA |
||
150 | |||
151 | /* 4GB DMA on some platforms */ |
||
152 | #define GFP_DMA32 __GFP_DMA32 |
||
153 | |||
154 | |||
155 | #ifdef CONFIG_HIGHMEM |
||
156 | #define OPT_ZONE_HIGHMEM ZONE_HIGHMEM |
||
157 | #else |
||
158 | #define OPT_ZONE_HIGHMEM ZONE_NORMAL |
||
159 | #endif |
||
160 | |||
161 | #ifdef CONFIG_ZONE_DMA |
||
162 | #define OPT_ZONE_DMA ZONE_DMA |
||
163 | #else |
||
164 | #define OPT_ZONE_DMA ZONE_NORMAL |
||
165 | #endif |
||
166 | |||
167 | #ifdef CONFIG_ZONE_DMA32 |
||
168 | #define OPT_ZONE_DMA32 ZONE_DMA32 |
||
169 | #else |
||
170 | #define OPT_ZONE_DMA32 ZONE_NORMAL |
||
171 | #endif |
||
172 | |||
173 | /* |
||
174 | * GFP_ZONE_TABLE is a word size bitstring that is used for looking up the |
||
175 | * zone to use given the lowest 4 bits of gfp_t. Entries are ZONE_SHIFT long |
||
176 | * and there are 16 of them to cover all possible combinations of |
||
177 | * __GFP_DMA, __GFP_DMA32, __GFP_MOVABLE and __GFP_HIGHMEM. |
||
178 | * |
||
179 | * The zone fallback order is MOVABLE=>HIGHMEM=>NORMAL=>DMA32=>DMA. |
||
180 | * But GFP_MOVABLE is not only a zone specifier but also an allocation |
||
181 | * policy. Therefore __GFP_MOVABLE plus another zone selector is valid. |
||
182 | * Only 1 bit of the lowest 3 bits (DMA,DMA32,HIGHMEM) can be set to "1". |
||
183 | * |
||
184 | * bit result |
||
185 | * ================= |
||
186 | * 0x0 => NORMAL |
||
187 | * 0x1 => DMA or NORMAL |
||
188 | * 0x2 => HIGHMEM or NORMAL |
||
189 | * 0x3 => BAD (DMA+HIGHMEM) |
||
190 | * 0x4 => DMA32 or DMA or NORMAL |
||
191 | * 0x5 => BAD (DMA+DMA32) |
||
192 | * 0x6 => BAD (HIGHMEM+DMA32) |
||
193 | * 0x7 => BAD (HIGHMEM+DMA32+DMA) |
||
194 | * 0x8 => NORMAL (MOVABLE+0) |
||
195 | * 0x9 => DMA or NORMAL (MOVABLE+DMA) |
||
196 | * 0xa => MOVABLE (Movable is valid only if HIGHMEM is set too) |
||
197 | * 0xb => BAD (MOVABLE+HIGHMEM+DMA) |
||
198 | * 0xc => DMA32 (MOVABLE+DMA32) |
||
199 | * 0xd => BAD (MOVABLE+DMA32+DMA) |
||
200 | * 0xe => BAD (MOVABLE+DMA32+HIGHMEM) |
||
201 | * 0xf => BAD (MOVABLE+DMA32+HIGHMEM+DMA) |
||
202 | * |
||
203 | * ZONES_SHIFT must be <= 2 on 32 bit platforms. |
||
204 | */ |
||
205 | |||
206 | #if 16 * ZONES_SHIFT > BITS_PER_LONG |
||
207 | #error ZONES_SHIFT too large to create GFP_ZONE_TABLE integer |
||
208 | #endif |
||
209 | |||
210 | #define GFP_ZONE_TABLE ( \ |
||
211 | (ZONE_NORMAL << 0 * ZONES_SHIFT) \ |
||
212 | | (OPT_ZONE_DMA << ___GFP_DMA * ZONES_SHIFT) \ |
||
213 | | (OPT_ZONE_HIGHMEM << ___GFP_HIGHMEM * ZONES_SHIFT) \ |
||
214 | | (OPT_ZONE_DMA32 << ___GFP_DMA32 * ZONES_SHIFT) \ |
||
215 | | (ZONE_NORMAL << ___GFP_MOVABLE * ZONES_SHIFT) \ |
||
216 | | (OPT_ZONE_DMA << (___GFP_MOVABLE | ___GFP_DMA) * ZONES_SHIFT) \ |
||
217 | | (ZONE_MOVABLE << (___GFP_MOVABLE | ___GFP_HIGHMEM) * ZONES_SHIFT) \ |
||
218 | | (OPT_ZONE_DMA32 << (___GFP_MOVABLE | ___GFP_DMA32) * ZONES_SHIFT) \ |
||
219 | ) |
||
220 | |||
221 | /* |
||
222 | * GFP_ZONE_BAD is a bitmap for all combinations of __GFP_DMA, __GFP_DMA32 |
||
223 | * __GFP_HIGHMEM and __GFP_MOVABLE that are not permitted. One flag per |
||
224 | * entry starting with bit 0. Bit is set if the combination is not |
||
225 | * allowed. |
||
226 | */ |
||
227 | #define GFP_ZONE_BAD ( \ |
||
228 | 1 << (___GFP_DMA | ___GFP_HIGHMEM) \ |
||
229 | | 1 << (___GFP_DMA | ___GFP_DMA32) \ |
||
230 | | 1 << (___GFP_DMA32 | ___GFP_HIGHMEM) \ |
||
231 | | 1 << (___GFP_DMA | ___GFP_DMA32 | ___GFP_HIGHMEM) \ |
||
232 | | 1 << (___GFP_MOVABLE | ___GFP_HIGHMEM | ___GFP_DMA) \ |
||
233 | | 1 << (___GFP_MOVABLE | ___GFP_DMA32 | ___GFP_DMA) \ |
||
234 | | 1 << (___GFP_MOVABLE | ___GFP_DMA32 | ___GFP_HIGHMEM) \ |
||
235 | | 1 << (___GFP_MOVABLE | ___GFP_DMA32 | ___GFP_DMA | ___GFP_HIGHMEM) \ |
||
236 | ) |
||
237 | |||
238 | |||
239 | #endif /* __LINUX_GFP_H */><>><>><>><>><>><>><>><>><>><>><>><>><>><>><>><>=>><> |