diff options
Diffstat (limited to 'include/linux/gfp.h')
-rw-r--r-- | include/linux/gfp.h | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/include/linux/gfp.h b/include/linux/gfp.h index 164be9da3c1b..c37653b6843f 100644 --- a/include/linux/gfp.h +++ b/include/linux/gfp.h | |||
@@ -119,35 +119,22 @@ static inline int allocflags_to_migratetype(gfp_t gfp_flags) | |||
119 | 119 | ||
120 | static inline enum zone_type gfp_zone(gfp_t flags) | 120 | static inline enum zone_type gfp_zone(gfp_t flags) |
121 | { | 121 | { |
122 | int base = 0; | ||
123 | |||
124 | #ifdef CONFIG_NUMA | ||
125 | if (flags & __GFP_THISNODE) | ||
126 | base = MAX_NR_ZONES; | ||
127 | #endif | ||
128 | |||
129 | #ifdef CONFIG_ZONE_DMA | 122 | #ifdef CONFIG_ZONE_DMA |
130 | if (flags & __GFP_DMA) | 123 | if (flags & __GFP_DMA) |
131 | return base + ZONE_DMA; | 124 | return ZONE_DMA; |
132 | #endif | 125 | #endif |
133 | #ifdef CONFIG_ZONE_DMA32 | 126 | #ifdef CONFIG_ZONE_DMA32 |
134 | if (flags & __GFP_DMA32) | 127 | if (flags & __GFP_DMA32) |
135 | return base + ZONE_DMA32; | 128 | return ZONE_DMA32; |
136 | #endif | 129 | #endif |
137 | if ((flags & (__GFP_HIGHMEM | __GFP_MOVABLE)) == | 130 | if ((flags & (__GFP_HIGHMEM | __GFP_MOVABLE)) == |
138 | (__GFP_HIGHMEM | __GFP_MOVABLE)) | 131 | (__GFP_HIGHMEM | __GFP_MOVABLE)) |
139 | return base + ZONE_MOVABLE; | 132 | return ZONE_MOVABLE; |
140 | #ifdef CONFIG_HIGHMEM | 133 | #ifdef CONFIG_HIGHMEM |
141 | if (flags & __GFP_HIGHMEM) | 134 | if (flags & __GFP_HIGHMEM) |
142 | return base + ZONE_HIGHMEM; | 135 | return ZONE_HIGHMEM; |
143 | #endif | 136 | #endif |
144 | return base + ZONE_NORMAL; | 137 | return ZONE_NORMAL; |
145 | } | ||
146 | |||
147 | static inline gfp_t set_migrateflags(gfp_t gfp, gfp_t migrate_flags) | ||
148 | { | ||
149 | BUG_ON((gfp & GFP_MOVABLE_MASK) == GFP_MOVABLE_MASK); | ||
150 | return (gfp & ~(GFP_MOVABLE_MASK)) | migrate_flags; | ||
151 | } | 138 | } |
152 | 139 | ||
153 | /* | 140 | /* |
@@ -157,13 +144,27 @@ static inline gfp_t set_migrateflags(gfp_t gfp, gfp_t migrate_flags) | |||
157 | * virtual kernel addresses to the allocated page(s). | 144 | * virtual kernel addresses to the allocated page(s). |
158 | */ | 145 | */ |
159 | 146 | ||
147 | static inline int gfp_zonelist(gfp_t flags) | ||
148 | { | ||
149 | if (NUMA_BUILD && unlikely(flags & __GFP_THISNODE)) | ||
150 | return 1; | ||
151 | |||
152 | return 0; | ||
153 | } | ||
154 | |||
160 | /* | 155 | /* |
161 | * We get the zone list from the current node and the gfp_mask. | 156 | * We get the zone list from the current node and the gfp_mask. |
162 | * This zone list contains a maximum of MAXNODES*MAX_NR_ZONES zones. | 157 | * This zone list contains a maximum of MAXNODES*MAX_NR_ZONES zones. |
158 | * There are two zonelists per node, one for all zones with memory and | ||
159 | * one containing just zones from the node the zonelist belongs to. | ||
163 | * | 160 | * |
164 | * For the normal case of non-DISCONTIGMEM systems the NODE_DATA() gets | 161 | * For the normal case of non-DISCONTIGMEM systems the NODE_DATA() gets |
165 | * optimized to &contig_page_data at compile-time. | 162 | * optimized to &contig_page_data at compile-time. |
166 | */ | 163 | */ |
164 | static inline struct zonelist *node_zonelist(int nid, gfp_t flags) | ||
165 | { | ||
166 | return NODE_DATA(nid)->node_zonelists + gfp_zonelist(flags); | ||
167 | } | ||
167 | 168 | ||
168 | #ifndef HAVE_ARCH_FREE_PAGE | 169 | #ifndef HAVE_ARCH_FREE_PAGE |
169 | static inline void arch_free_page(struct page *page, int order) { } | 170 | static inline void arch_free_page(struct page *page, int order) { } |
@@ -174,6 +175,10 @@ static inline void arch_alloc_page(struct page *page, int order) { } | |||
174 | 175 | ||
175 | extern struct page *__alloc_pages(gfp_t, unsigned int, struct zonelist *); | 176 | extern struct page *__alloc_pages(gfp_t, unsigned int, struct zonelist *); |
176 | 177 | ||
178 | extern struct page * | ||
179 | __alloc_pages_nodemask(gfp_t, unsigned int, | ||
180 | struct zonelist *, nodemask_t *nodemask); | ||
181 | |||
177 | static inline struct page *alloc_pages_node(int nid, gfp_t gfp_mask, | 182 | static inline struct page *alloc_pages_node(int nid, gfp_t gfp_mask, |
178 | unsigned int order) | 183 | unsigned int order) |
179 | { | 184 | { |
@@ -184,8 +189,7 @@ static inline struct page *alloc_pages_node(int nid, gfp_t gfp_mask, | |||
184 | if (nid < 0) | 189 | if (nid < 0) |
185 | nid = numa_node_id(); | 190 | nid = numa_node_id(); |
186 | 191 | ||
187 | return __alloc_pages(gfp_mask, order, | 192 | return __alloc_pages(gfp_mask, order, node_zonelist(nid, gfp_mask)); |
188 | NODE_DATA(nid)->node_zonelists + gfp_zone(gfp_mask)); | ||
189 | } | 193 | } |
190 | 194 | ||
191 | #ifdef CONFIG_NUMA | 195 | #ifdef CONFIG_NUMA |