diff options
author | Namhyung Kim <namhyung@gmail.com> | 2010-10-26 17:22:04 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-10-26 19:52:10 -0400 |
commit | 16b56cf4b8a0fa9acc21bd2ad19839b917999b96 (patch) | |
tree | 174dcc56e46bf5f939824031957270b4a9f7a9c6 /include/linux/gfp.h | |
parent | 36deb0be314702627aeae1f5737fc84d01dc26c6 (diff) |
mm: fix sparse warnings on GFP_ZONE_TABLE/BAD
Introduce ___GFP_* masks in order for gfp_t to not be mixed with plain
integers which causes a lot of warnings like the following:
warning: restricted gfp_t degrades to integer
Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/gfp.h')
-rw-r--r-- | include/linux/gfp.h | 105 |
1 files changed, 63 insertions, 42 deletions
diff --git a/include/linux/gfp.h b/include/linux/gfp.h index 975609cb8548..e8713d55360a 100644 --- a/include/linux/gfp.h +++ b/include/linux/gfp.h | |||
@@ -9,6 +9,32 @@ | |||
9 | 9 | ||
10 | struct vm_area_struct; | 10 | struct vm_area_struct; |
11 | 11 | ||
12 | /* Plain integer GFP bitmasks. Do not use this directly. */ | ||
13 | #define ___GFP_DMA 0x01u | ||
14 | #define ___GFP_HIGHMEM 0x02u | ||
15 | #define ___GFP_DMA32 0x04u | ||
16 | #define ___GFP_MOVABLE 0x08u | ||
17 | #define ___GFP_WAIT 0x10u | ||
18 | #define ___GFP_HIGH 0x20u | ||
19 | #define ___GFP_IO 0x40u | ||
20 | #define ___GFP_FS 0x80u | ||
21 | #define ___GFP_COLD 0x100u | ||
22 | #define ___GFP_NOWARN 0x200u | ||
23 | #define ___GFP_REPEAT 0x400u | ||
24 | #define ___GFP_NOFAIL 0x800u | ||
25 | #define ___GFP_NORETRY 0x1000u | ||
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 | #ifdef CONFIG_KMEMCHECK | ||
33 | #define ___GFP_NOTRACK 0x200000u | ||
34 | #else | ||
35 | #define ___GFP_NOTRACK 0 | ||
36 | #endif | ||
37 | |||
12 | /* | 38 | /* |
13 | * GFP bitmasks.. | 39 | * GFP bitmasks.. |
14 | * | 40 | * |
@@ -18,10 +44,10 @@ struct vm_area_struct; | |||
18 | * without the underscores and use them consistently. The definitions here may | 44 | * without the underscores and use them consistently. The definitions here may |
19 | * be used in bit comparisons. | 45 | * be used in bit comparisons. |
20 | */ | 46 | */ |
21 | #define __GFP_DMA ((__force gfp_t)0x01u) | 47 | #define __GFP_DMA ((__force gfp_t)___GFP_DMA) |
22 | #define __GFP_HIGHMEM ((__force gfp_t)0x02u) | 48 | #define __GFP_HIGHMEM ((__force gfp_t)___GFP_HIGHMEM) |
23 | #define __GFP_DMA32 ((__force gfp_t)0x04u) | 49 | #define __GFP_DMA32 ((__force gfp_t)___GFP_DMA32) |
24 | #define __GFP_MOVABLE ((__force gfp_t)0x08u) /* Page is movable */ | 50 | #define __GFP_MOVABLE ((__force gfp_t)___GFP_MOVABLE) /* Page is movable */ |
25 | #define GFP_ZONEMASK (__GFP_DMA|__GFP_HIGHMEM|__GFP_DMA32|__GFP_MOVABLE) | 51 | #define GFP_ZONEMASK (__GFP_DMA|__GFP_HIGHMEM|__GFP_DMA32|__GFP_MOVABLE) |
26 | /* | 52 | /* |
27 | * Action modifiers - doesn't change the zoning | 53 | * Action modifiers - doesn't change the zoning |
@@ -38,27 +64,22 @@ struct vm_area_struct; | |||
38 | * __GFP_MOVABLE: Flag that this page will be movable by the page migration | 64 | * __GFP_MOVABLE: Flag that this page will be movable by the page migration |
39 | * mechanism or reclaimed | 65 | * mechanism or reclaimed |
40 | */ | 66 | */ |
41 | #define __GFP_WAIT ((__force gfp_t)0x10u) /* Can wait and reschedule? */ | 67 | #define __GFP_WAIT ((__force gfp_t)___GFP_WAIT) /* Can wait and reschedule? */ |
42 | #define __GFP_HIGH ((__force gfp_t)0x20u) /* Should access emergency pools? */ | 68 | #define __GFP_HIGH ((__force gfp_t)___GFP_HIGH) /* Should access emergency pools? */ |
43 | #define __GFP_IO ((__force gfp_t)0x40u) /* Can start physical IO? */ | 69 | #define __GFP_IO ((__force gfp_t)___GFP_IO) /* Can start physical IO? */ |
44 | #define __GFP_FS ((__force gfp_t)0x80u) /* Can call down to low-level FS? */ | 70 | #define __GFP_FS ((__force gfp_t)___GFP_FS) /* Can call down to low-level FS? */ |
45 | #define __GFP_COLD ((__force gfp_t)0x100u) /* Cache-cold page required */ | 71 | #define __GFP_COLD ((__force gfp_t)___GFP_COLD) /* Cache-cold page required */ |
46 | #define __GFP_NOWARN ((__force gfp_t)0x200u) /* Suppress page allocation failure warning */ | 72 | #define __GFP_NOWARN ((__force gfp_t)___GFP_NOWARN) /* Suppress page allocation failure warning */ |
47 | #define __GFP_REPEAT ((__force gfp_t)0x400u) /* See above */ | 73 | #define __GFP_REPEAT ((__force gfp_t)___GFP_REPEAT) /* See above */ |
48 | #define __GFP_NOFAIL ((__force gfp_t)0x800u) /* See above */ | 74 | #define __GFP_NOFAIL ((__force gfp_t)___GFP_NOFAIL) /* See above */ |
49 | #define __GFP_NORETRY ((__force gfp_t)0x1000u)/* See above */ | 75 | #define __GFP_NORETRY ((__force gfp_t)___GFP_NORETRY) /* See above */ |
50 | #define __GFP_COMP ((__force gfp_t)0x4000u)/* Add compound page metadata */ | 76 | #define __GFP_COMP ((__force gfp_t)___GFP_COMP) /* Add compound page metadata */ |
51 | #define __GFP_ZERO ((__force gfp_t)0x8000u)/* Return zeroed page on success */ | 77 | #define __GFP_ZERO ((__force gfp_t)___GFP_ZERO) /* Return zeroed page on success */ |
52 | #define __GFP_NOMEMALLOC ((__force gfp_t)0x10000u) /* Don't use emergency reserves */ | 78 | #define __GFP_NOMEMALLOC ((__force gfp_t)___GFP_NOMEMALLOC) /* Don't use emergency reserves */ |
53 | #define __GFP_HARDWALL ((__force gfp_t)0x20000u) /* Enforce hardwall cpuset memory allocs */ | 79 | #define __GFP_HARDWALL ((__force gfp_t)___GFP_HARDWALL) /* Enforce hardwall cpuset memory allocs */ |
54 | #define __GFP_THISNODE ((__force gfp_t)0x40000u)/* No fallback, no policies */ | 80 | #define __GFP_THISNODE ((__force gfp_t)___GFP_THISNODE)/* No fallback, no policies */ |
55 | #define __GFP_RECLAIMABLE ((__force gfp_t)0x80000u) /* Page is reclaimable */ | 81 | #define __GFP_RECLAIMABLE ((__force gfp_t)___GFP_RECLAIMABLE) /* Page is reclaimable */ |
56 | 82 | #define __GFP_NOTRACK ((__force gfp_t)___GFP_NOTRACK) /* Don't track with kmemcheck */ | |
57 | #ifdef CONFIG_KMEMCHECK | ||
58 | #define __GFP_NOTRACK ((__force gfp_t)0x200000u) /* Don't track with kmemcheck */ | ||
59 | #else | ||
60 | #define __GFP_NOTRACK ((__force gfp_t)0) | ||
61 | #endif | ||
62 | 83 | ||
63 | /* | 84 | /* |
64 | * This may seem redundant, but it's a way of annotating false positives vs. | 85 | * This may seem redundant, but it's a way of annotating false positives vs. |
@@ -186,14 +207,14 @@ static inline int allocflags_to_migratetype(gfp_t gfp_flags) | |||
186 | #endif | 207 | #endif |
187 | 208 | ||
188 | #define GFP_ZONE_TABLE ( \ | 209 | #define GFP_ZONE_TABLE ( \ |
189 | (ZONE_NORMAL << 0 * ZONES_SHIFT) \ | 210 | (ZONE_NORMAL << 0 * ZONES_SHIFT) \ |
190 | | (OPT_ZONE_DMA << __GFP_DMA * ZONES_SHIFT) \ | 211 | | (OPT_ZONE_DMA << ___GFP_DMA * ZONES_SHIFT) \ |
191 | | (OPT_ZONE_HIGHMEM << __GFP_HIGHMEM * ZONES_SHIFT) \ | 212 | | (OPT_ZONE_HIGHMEM << ___GFP_HIGHMEM * ZONES_SHIFT) \ |
192 | | (OPT_ZONE_DMA32 << __GFP_DMA32 * ZONES_SHIFT) \ | 213 | | (OPT_ZONE_DMA32 << ___GFP_DMA32 * ZONES_SHIFT) \ |
193 | | (ZONE_NORMAL << __GFP_MOVABLE * ZONES_SHIFT) \ | 214 | | (ZONE_NORMAL << ___GFP_MOVABLE * ZONES_SHIFT) \ |
194 | | (OPT_ZONE_DMA << (__GFP_MOVABLE | __GFP_DMA) * ZONES_SHIFT) \ | 215 | | (OPT_ZONE_DMA << (___GFP_MOVABLE | ___GFP_DMA) * ZONES_SHIFT) \ |
195 | | (ZONE_MOVABLE << (__GFP_MOVABLE | __GFP_HIGHMEM) * ZONES_SHIFT)\ | 216 | | (ZONE_MOVABLE << (___GFP_MOVABLE | ___GFP_HIGHMEM) * ZONES_SHIFT) \ |
196 | | (OPT_ZONE_DMA32 << (__GFP_MOVABLE | __GFP_DMA32) * ZONES_SHIFT)\ | 217 | | (OPT_ZONE_DMA32 << (___GFP_MOVABLE | ___GFP_DMA32) * ZONES_SHIFT) \ |
197 | ) | 218 | ) |
198 | 219 | ||
199 | /* | 220 | /* |
@@ -203,20 +224,20 @@ static inline int allocflags_to_migratetype(gfp_t gfp_flags) | |||
203 | * allowed. | 224 | * allowed. |
204 | */ | 225 | */ |
205 | #define GFP_ZONE_BAD ( \ | 226 | #define GFP_ZONE_BAD ( \ |
206 | 1 << (__GFP_DMA | __GFP_HIGHMEM) \ | 227 | 1 << (___GFP_DMA | ___GFP_HIGHMEM) \ |
207 | | 1 << (__GFP_DMA | __GFP_DMA32) \ | 228 | | 1 << (___GFP_DMA | ___GFP_DMA32) \ |
208 | | 1 << (__GFP_DMA32 | __GFP_HIGHMEM) \ | 229 | | 1 << (___GFP_DMA32 | ___GFP_HIGHMEM) \ |
209 | | 1 << (__GFP_DMA | __GFP_DMA32 | __GFP_HIGHMEM) \ | 230 | | 1 << (___GFP_DMA | ___GFP_DMA32 | ___GFP_HIGHMEM) \ |
210 | | 1 << (__GFP_MOVABLE | __GFP_HIGHMEM | __GFP_DMA) \ | 231 | | 1 << (___GFP_MOVABLE | ___GFP_HIGHMEM | ___GFP_DMA) \ |
211 | | 1 << (__GFP_MOVABLE | __GFP_DMA32 | __GFP_DMA) \ | 232 | | 1 << (___GFP_MOVABLE | ___GFP_DMA32 | ___GFP_DMA) \ |
212 | | 1 << (__GFP_MOVABLE | __GFP_DMA32 | __GFP_HIGHMEM) \ | 233 | | 1 << (___GFP_MOVABLE | ___GFP_DMA32 | ___GFP_HIGHMEM) \ |
213 | | 1 << (__GFP_MOVABLE | __GFP_DMA32 | __GFP_DMA | __GFP_HIGHMEM)\ | 234 | | 1 << (___GFP_MOVABLE | ___GFP_DMA32 | ___GFP_DMA | ___GFP_HIGHMEM) \ |
214 | ) | 235 | ) |
215 | 236 | ||
216 | static inline enum zone_type gfp_zone(gfp_t flags) | 237 | static inline enum zone_type gfp_zone(gfp_t flags) |
217 | { | 238 | { |
218 | enum zone_type z; | 239 | enum zone_type z; |
219 | int bit = flags & GFP_ZONEMASK; | 240 | int bit = (__force int) (flags & GFP_ZONEMASK); |
220 | 241 | ||
221 | z = (GFP_ZONE_TABLE >> (bit * ZONES_SHIFT)) & | 242 | z = (GFP_ZONE_TABLE >> (bit * ZONES_SHIFT)) & |
222 | ((1 << ZONES_SHIFT) - 1); | 243 | ((1 << ZONES_SHIFT) - 1); |