5 #include <linux/stddef.h>
6 #include <linux/linkage.h>
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_MEMALLOC 0x2000u
27 #define ___GFP_COMP 0x4000u
28 #define ___GFP_ZERO 0x8000u
29 #define ___GFP_NOMEMALLOC 0x10000u
30 #define ___GFP_HARDWALL 0x20000u
31 #define ___GFP_THISNODE 0x40000u
32 #define ___GFP_RECLAIMABLE 0x80000u
33 #define ___GFP_NOTRACK 0x200000u
34 #define ___GFP_NO_KSWAPD 0x400000u
35 #define ___GFP_OTHER_NODE 0x800000u
36 #define ___GFP_WRITE 0x1000000u
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)
51 #define GFP_ZONEMASK (__GFP_DMA|__GFP_HIGHMEM|__GFP_DMA32|__GFP_MOVABLE)
67 #define __GFP_WAIT ((__force gfp_t)___GFP_WAIT)
68 #define __GFP_HIGH ((__force gfp_t)___GFP_HIGH)
69 #define __GFP_IO ((__force gfp_t)___GFP_IO)
70 #define __GFP_FS ((__force gfp_t)___GFP_FS)
71 #define __GFP_COLD ((__force gfp_t)___GFP_COLD)
72 #define __GFP_NOWARN ((__force gfp_t)___GFP_NOWARN)
73 #define __GFP_REPEAT ((__force gfp_t)___GFP_REPEAT)
74 #define __GFP_NOFAIL ((__force gfp_t)___GFP_NOFAIL)
75 #define __GFP_NORETRY ((__force gfp_t)___GFP_NORETRY)
76 #define __GFP_MEMALLOC ((__force gfp_t)___GFP_MEMALLOC)
77 #define __GFP_COMP ((__force gfp_t)___GFP_COMP)
78 #define __GFP_ZERO ((__force gfp_t)___GFP_ZERO)
79 #define __GFP_NOMEMALLOC ((__force gfp_t)___GFP_NOMEMALLOC)
84 #define __GFP_HARDWALL ((__force gfp_t)___GFP_HARDWALL)
85 #define __GFP_THISNODE ((__force gfp_t)___GFP_THISNODE)
86 #define __GFP_RECLAIMABLE ((__force gfp_t)___GFP_RECLAIMABLE)
87 #define __GFP_NOTRACK ((__force gfp_t)___GFP_NOTRACK)
89 #define __GFP_NO_KSWAPD ((__force gfp_t)___GFP_NO_KSWAPD)
90 #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE)
91 #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE)
97 #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
99 #define __GFP_BITS_SHIFT 25
100 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
103 #define GFP_NOWAIT (GFP_ATOMIC & ~__GFP_HIGH)
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 | \
111 #define GFP_USER (__GFP_WAIT | __GFP_IO | __GFP_FS | __GFP_HARDWALL)
112 #define GFP_HIGHUSER (__GFP_WAIT | __GFP_IO | __GFP_FS | __GFP_HARDWALL | \
114 #define GFP_HIGHUSER_MOVABLE (__GFP_WAIT | __GFP_IO | __GFP_FS | \
115 __GFP_HARDWALL | __GFP_HIGHMEM | \
117 #define GFP_IOFS (__GFP_IO | __GFP_FS)
118 #define GFP_TRANSHUGE (GFP_HIGHUSER_MOVABLE | __GFP_COMP | \
119 __GFP_NOMEMALLOC | __GFP_NORETRY | __GFP_NOWARN | \
123 #define GFP_THISNODE (__GFP_THISNODE | __GFP_NOWARN | __GFP_NORETRY)
125 #define GFP_THISNODE ((__force gfp_t)0)
129 #define GFP_MOVABLE_MASK (__GFP_RECLAIMABLE|__GFP_MOVABLE)
132 #define GFP_RECLAIM_MASK (__GFP_WAIT|__GFP_HIGH|__GFP_IO|__GFP_FS|\
133 __GFP_NOWARN|__GFP_REPEAT|__GFP_NOFAIL|\
134 __GFP_NORETRY|__GFP_MEMALLOC|__GFP_NOMEMALLOC)
137 #define GFP_BOOT_MASK (__GFP_BITS_MASK & ~(__GFP_WAIT|__GFP_IO|__GFP_FS))
140 #define GFP_CONSTRAINT_MASK (__GFP_HARDWALL|__GFP_THISNODE)
143 #define GFP_SLAB_BUG_MASK (__GFP_DMA32|__GFP_HIGHMEM|~__GFP_BITS_MASK)
148 #define GFP_DMA __GFP_DMA
151 #define GFP_DMA32 __GFP_DMA32
154 static inline int allocflags_to_migratetype(
gfp_t gfp_flags)
166 #ifdef CONFIG_HIGHMEM
167 #define OPT_ZONE_HIGHMEM ZONE_HIGHMEM
169 #define OPT_ZONE_HIGHMEM ZONE_NORMAL
172 #ifdef CONFIG_ZONE_DMA
173 #define OPT_ZONE_DMA ZONE_DMA
175 #define OPT_ZONE_DMA ZONE_NORMAL
178 #ifdef CONFIG_ZONE_DMA32
179 #define OPT_ZONE_DMA32 ZONE_DMA32
181 #define OPT_ZONE_DMA32 ZONE_NORMAL
217 #if 16 * ZONES_SHIFT > BITS_PER_LONG
218 #error ZONES_SHIFT too large to create GFP_ZONE_TABLE integer
221 #define GFP_ZONE_TABLE ( \
222 (ZONE_NORMAL << 0 * ZONES_SHIFT) \
223 | (OPT_ZONE_DMA << ___GFP_DMA * ZONES_SHIFT) \
224 | (OPT_ZONE_HIGHMEM << ___GFP_HIGHMEM * ZONES_SHIFT) \
225 | (OPT_ZONE_DMA32 << ___GFP_DMA32 * ZONES_SHIFT) \
226 | (ZONE_NORMAL << ___GFP_MOVABLE * ZONES_SHIFT) \
227 | (OPT_ZONE_DMA << (___GFP_MOVABLE | ___GFP_DMA) * ZONES_SHIFT) \
228 | (ZONE_MOVABLE << (___GFP_MOVABLE | ___GFP_HIGHMEM) * ZONES_SHIFT) \
229 | (OPT_ZONE_DMA32 << (___GFP_MOVABLE | ___GFP_DMA32) * ZONES_SHIFT) \
238 #define GFP_ZONE_BAD ( \
239 1 << (___GFP_DMA | ___GFP_HIGHMEM) \
240 | 1 << (___GFP_DMA | ___GFP_DMA32) \
241 | 1 << (___GFP_DMA32 | ___GFP_HIGHMEM) \
242 | 1 << (___GFP_DMA | ___GFP_DMA32 | ___GFP_HIGHMEM) \
243 | 1 << (___GFP_MOVABLE | ___GFP_HIGHMEM | ___GFP_DMA) \
244 | 1 << (___GFP_MOVABLE | ___GFP_DMA32 | ___GFP_DMA) \
245 | 1 << (___GFP_MOVABLE | ___GFP_DMA32 | ___GFP_HIGHMEM) \
246 | 1 << (___GFP_MOVABLE | ___GFP_DMA32 | ___GFP_DMA | ___GFP_HIGHMEM) \
284 static inline struct zonelist *node_zonelist(
int nid,
gfp_t flags)
286 return NODE_DATA(nid)->node_zonelists + gfp_zonelist(flags);
289 #ifndef HAVE_ARCH_FREE_PAGE
292 #ifndef HAVE_ARCH_ALLOC_PAGE
300 static inline struct page *
314 return __alloc_pages(gfp_mask, order, node_zonelist(nid, gfp_mask));
317 static inline struct page *alloc_pages_exact_node(
int nid,
gfp_t gfp_mask,
322 return __alloc_pages(gfp_mask, order, node_zonelist(nid, gfp_mask));
328 static inline struct page *
337 #define alloc_pages(gfp_mask, order) \
338 alloc_pages_node(numa_node_id(), gfp_mask, order)
339 #define alloc_pages_vma(gfp_mask, order, vma, addr, node) \
340 alloc_pages(gfp_mask, order)
342 #define alloc_page(gfp_mask) alloc_pages(gfp_mask, 0)
343 #define alloc_page_vma(gfp_mask, vma, addr) \
344 alloc_pages_vma(gfp_mask, 0, vma, addr, numa_node_id())
345 #define alloc_page_vma_node(gfp_mask, vma, addr, node) \
346 alloc_pages_vma(gfp_mask, 0, vma, addr, node)
356 #define __get_free_page(gfp_mask) \
357 __get_free_pages((gfp_mask), 0)
359 #define __get_dma_pages(gfp_mask, order) \
360 __get_free_pages((gfp_mask) | GFP_DMA, (order))
367 #define __free_page(page) __free_pages((page), 0)
368 #define free_page(addr) free_pages((addr), 0)
390 #ifdef CONFIG_PM_SLEEP
391 extern bool pm_suspended_storage(
void);
393 static inline bool pm_suspended_storage(
void)
402 extern int alloc_contig_range(
unsigned long start,
unsigned long end,
403 unsigned migratetype);
404 extern void free_contig_range(
unsigned long pfn,
unsigned nr_pages);
407 extern void init_cma_reserved_pageblock(
struct page *
page);