diff options
Diffstat (limited to 'mm/bootmem.c')
-rw-r--r-- | mm/bootmem.c | 202 |
1 files changed, 113 insertions, 89 deletions
diff --git a/mm/bootmem.c b/mm/bootmem.c index 50353e0dac12..d53112fcb404 100644 --- a/mm/bootmem.c +++ b/mm/bootmem.c | |||
@@ -8,17 +8,15 @@ | |||
8 | * free memory collector. It's used to deal with reserved | 8 | * free memory collector. It's used to deal with reserved |
9 | * system memory and memory holes as well. | 9 | * system memory and memory holes as well. |
10 | */ | 10 | */ |
11 | |||
12 | #include <linux/mm.h> | ||
13 | #include <linux/kernel_stat.h> | ||
14 | #include <linux/swap.h> | ||
15 | #include <linux/interrupt.h> | ||
16 | #include <linux/init.h> | 11 | #include <linux/init.h> |
12 | #include <linux/pfn.h> | ||
17 | #include <linux/bootmem.h> | 13 | #include <linux/bootmem.h> |
18 | #include <linux/mmzone.h> | ||
19 | #include <linux/module.h> | 14 | #include <linux/module.h> |
20 | #include <asm/dma.h> | 15 | |
16 | #include <asm/bug.h> | ||
21 | #include <asm/io.h> | 17 | #include <asm/io.h> |
18 | #include <asm/processor.h> | ||
19 | |||
22 | #include "internal.h" | 20 | #include "internal.h" |
23 | 21 | ||
24 | /* | 22 | /* |
@@ -41,7 +39,7 @@ unsigned long saved_max_pfn; | |||
41 | #endif | 39 | #endif |
42 | 40 | ||
43 | /* return the number of _pages_ that will be allocated for the boot bitmap */ | 41 | /* return the number of _pages_ that will be allocated for the boot bitmap */ |
44 | unsigned long __init bootmem_bootmap_pages (unsigned long pages) | 42 | unsigned long __init bootmem_bootmap_pages(unsigned long pages) |
45 | { | 43 | { |
46 | unsigned long mapsize; | 44 | unsigned long mapsize; |
47 | 45 | ||
@@ -51,12 +49,14 @@ unsigned long __init bootmem_bootmap_pages (unsigned long pages) | |||
51 | 49 | ||
52 | return mapsize; | 50 | return mapsize; |
53 | } | 51 | } |
52 | |||
54 | /* | 53 | /* |
55 | * link bdata in order | 54 | * link bdata in order |
56 | */ | 55 | */ |
57 | static void link_bootmem(bootmem_data_t *bdata) | 56 | static void __init link_bootmem(bootmem_data_t *bdata) |
58 | { | 57 | { |
59 | bootmem_data_t *ent; | 58 | bootmem_data_t *ent; |
59 | |||
60 | if (list_empty(&bdata_list)) { | 60 | if (list_empty(&bdata_list)) { |
61 | list_add(&bdata->list, &bdata_list); | 61 | list_add(&bdata->list, &bdata_list); |
62 | return; | 62 | return; |
@@ -69,22 +69,32 @@ static void link_bootmem(bootmem_data_t *bdata) | |||
69 | } | 69 | } |
70 | } | 70 | } |
71 | list_add_tail(&bdata->list, &bdata_list); | 71 | list_add_tail(&bdata->list, &bdata_list); |
72 | return; | ||
73 | } | 72 | } |
74 | 73 | ||
74 | /* | ||
75 | * Given an initialised bdata, it returns the size of the boot bitmap | ||
76 | */ | ||
77 | static unsigned long __init get_mapsize(bootmem_data_t *bdata) | ||
78 | { | ||
79 | unsigned long mapsize; | ||
80 | unsigned long start = PFN_DOWN(bdata->node_boot_start); | ||
81 | unsigned long end = bdata->node_low_pfn; | ||
82 | |||
83 | mapsize = ((end - start) + 7) / 8; | ||
84 | return ALIGN(mapsize, sizeof(long)); | ||
85 | } | ||
75 | 86 | ||
76 | /* | 87 | /* |
77 | * Called once to set up the allocator itself. | 88 | * Called once to set up the allocator itself. |
78 | */ | 89 | */ |
79 | static unsigned long __init init_bootmem_core (pg_data_t *pgdat, | 90 | static unsigned long __init init_bootmem_core(pg_data_t *pgdat, |
80 | unsigned long mapstart, unsigned long start, unsigned long end) | 91 | unsigned long mapstart, unsigned long start, unsigned long end) |
81 | { | 92 | { |
82 | bootmem_data_t *bdata = pgdat->bdata; | 93 | bootmem_data_t *bdata = pgdat->bdata; |
83 | unsigned long mapsize = ((end - start)+7)/8; | 94 | unsigned long mapsize; |
84 | 95 | ||
85 | mapsize = ALIGN(mapsize, sizeof(long)); | 96 | bdata->node_bootmem_map = phys_to_virt(PFN_PHYS(mapstart)); |
86 | bdata->node_bootmem_map = phys_to_virt(mapstart << PAGE_SHIFT); | 97 | bdata->node_boot_start = PFN_PHYS(start); |
87 | bdata->node_boot_start = (start << PAGE_SHIFT); | ||
88 | bdata->node_low_pfn = end; | 98 | bdata->node_low_pfn = end; |
89 | link_bootmem(bdata); | 99 | link_bootmem(bdata); |
90 | 100 | ||
@@ -92,6 +102,7 @@ static unsigned long __init init_bootmem_core (pg_data_t *pgdat, | |||
92 | * Initially all pages are reserved - setup_arch() has to | 102 | * Initially all pages are reserved - setup_arch() has to |
93 | * register free RAM areas explicitly. | 103 | * register free RAM areas explicitly. |
94 | */ | 104 | */ |
105 | mapsize = get_mapsize(bdata); | ||
95 | memset(bdata->node_bootmem_map, 0xff, mapsize); | 106 | memset(bdata->node_bootmem_map, 0xff, mapsize); |
96 | 107 | ||
97 | return mapsize; | 108 | return mapsize; |
@@ -102,22 +113,22 @@ static unsigned long __init init_bootmem_core (pg_data_t *pgdat, | |||
102 | * might be used for boot-time allocations - or it might get added | 113 | * might be used for boot-time allocations - or it might get added |
103 | * to the free page pool later on. | 114 | * to the free page pool later on. |
104 | */ | 115 | */ |
105 | static void __init reserve_bootmem_core(bootmem_data_t *bdata, unsigned long addr, unsigned long size) | 116 | static void __init reserve_bootmem_core(bootmem_data_t *bdata, unsigned long addr, |
117 | unsigned long size) | ||
106 | { | 118 | { |
119 | unsigned long sidx, eidx; | ||
107 | unsigned long i; | 120 | unsigned long i; |
121 | |||
108 | /* | 122 | /* |
109 | * round up, partially reserved pages are considered | 123 | * round up, partially reserved pages are considered |
110 | * fully reserved. | 124 | * fully reserved. |
111 | */ | 125 | */ |
112 | unsigned long sidx = (addr - bdata->node_boot_start)/PAGE_SIZE; | ||
113 | unsigned long eidx = (addr + size - bdata->node_boot_start + | ||
114 | PAGE_SIZE-1)/PAGE_SIZE; | ||
115 | unsigned long end = (addr + size + PAGE_SIZE-1)/PAGE_SIZE; | ||
116 | |||
117 | BUG_ON(!size); | 126 | BUG_ON(!size); |
118 | BUG_ON(sidx >= eidx); | 127 | BUG_ON(PFN_DOWN(addr) >= bdata->node_low_pfn); |
119 | BUG_ON((addr >> PAGE_SHIFT) >= bdata->node_low_pfn); | 128 | BUG_ON(PFN_UP(addr + size) > bdata->node_low_pfn); |
120 | BUG_ON(end > bdata->node_low_pfn); | 129 | |
130 | sidx = PFN_DOWN(addr - bdata->node_boot_start); | ||
131 | eidx = PFN_UP(addr + size - bdata->node_boot_start); | ||
121 | 132 | ||
122 | for (i = sidx; i < eidx; i++) | 133 | for (i = sidx; i < eidx; i++) |
123 | if (test_and_set_bit(i, bdata->node_bootmem_map)) { | 134 | if (test_and_set_bit(i, bdata->node_bootmem_map)) { |
@@ -127,20 +138,18 @@ static void __init reserve_bootmem_core(bootmem_data_t *bdata, unsigned long add | |||
127 | } | 138 | } |
128 | } | 139 | } |
129 | 140 | ||
130 | static void __init free_bootmem_core(bootmem_data_t *bdata, unsigned long addr, unsigned long size) | 141 | static void __init free_bootmem_core(bootmem_data_t *bdata, unsigned long addr, |
142 | unsigned long size) | ||
131 | { | 143 | { |
144 | unsigned long sidx, eidx; | ||
132 | unsigned long i; | 145 | unsigned long i; |
133 | unsigned long start; | 146 | |
134 | /* | 147 | /* |
135 | * round down end of usable mem, partially free pages are | 148 | * round down end of usable mem, partially free pages are |
136 | * considered reserved. | 149 | * considered reserved. |
137 | */ | 150 | */ |
138 | unsigned long sidx; | ||
139 | unsigned long eidx = (addr + size - bdata->node_boot_start)/PAGE_SIZE; | ||
140 | unsigned long end = (addr + size)/PAGE_SIZE; | ||
141 | |||
142 | BUG_ON(!size); | 151 | BUG_ON(!size); |
143 | BUG_ON(end > bdata->node_low_pfn); | 152 | BUG_ON(PFN_DOWN(addr + size) > bdata->node_low_pfn); |
144 | 153 | ||
145 | if (addr < bdata->last_success) | 154 | if (addr < bdata->last_success) |
146 | bdata->last_success = addr; | 155 | bdata->last_success = addr; |
@@ -148,8 +157,8 @@ static void __init free_bootmem_core(bootmem_data_t *bdata, unsigned long addr, | |||
148 | /* | 157 | /* |
149 | * Round up the beginning of the address. | 158 | * Round up the beginning of the address. |
150 | */ | 159 | */ |
151 | start = (addr + PAGE_SIZE-1) / PAGE_SIZE; | 160 | sidx = PFN_UP(addr) - PFN_DOWN(bdata->node_boot_start); |
152 | sidx = start - (bdata->node_boot_start/PAGE_SIZE); | 161 | eidx = PFN_DOWN(addr + size - bdata->node_boot_start); |
153 | 162 | ||
154 | for (i = sidx; i < eidx; i++) { | 163 | for (i = sidx; i < eidx; i++) { |
155 | if (unlikely(!test_and_clear_bit(i, bdata->node_bootmem_map))) | 164 | if (unlikely(!test_and_clear_bit(i, bdata->node_bootmem_map))) |
@@ -175,10 +184,10 @@ __alloc_bootmem_core(struct bootmem_data *bdata, unsigned long size, | |||
175 | unsigned long align, unsigned long goal, unsigned long limit) | 184 | unsigned long align, unsigned long goal, unsigned long limit) |
176 | { | 185 | { |
177 | unsigned long offset, remaining_size, areasize, preferred; | 186 | unsigned long offset, remaining_size, areasize, preferred; |
178 | unsigned long i, start = 0, incr, eidx, end_pfn = bdata->node_low_pfn; | 187 | unsigned long i, start = 0, incr, eidx, end_pfn; |
179 | void *ret; | 188 | void *ret; |
180 | 189 | ||
181 | if(!size) { | 190 | if (!size) { |
182 | printk("__alloc_bootmem_core(): zero-sized request\n"); | 191 | printk("__alloc_bootmem_core(): zero-sized request\n"); |
183 | BUG(); | 192 | BUG(); |
184 | } | 193 | } |
@@ -187,23 +196,22 @@ __alloc_bootmem_core(struct bootmem_data *bdata, unsigned long size, | |||
187 | if (limit && bdata->node_boot_start >= limit) | 196 | if (limit && bdata->node_boot_start >= limit) |
188 | return NULL; | 197 | return NULL; |
189 | 198 | ||
190 | limit >>=PAGE_SHIFT; | 199 | end_pfn = bdata->node_low_pfn; |
200 | limit = PFN_DOWN(limit); | ||
191 | if (limit && end_pfn > limit) | 201 | if (limit && end_pfn > limit) |
192 | end_pfn = limit; | 202 | end_pfn = limit; |
193 | 203 | ||
194 | eidx = end_pfn - (bdata->node_boot_start >> PAGE_SHIFT); | 204 | eidx = end_pfn - PFN_DOWN(bdata->node_boot_start); |
195 | offset = 0; | 205 | offset = 0; |
196 | if (align && | 206 | if (align && (bdata->node_boot_start & (align - 1UL)) != 0) |
197 | (bdata->node_boot_start & (align - 1UL)) != 0) | 207 | offset = align - (bdata->node_boot_start & (align - 1UL)); |
198 | offset = (align - (bdata->node_boot_start & (align - 1UL))); | 208 | offset = PFN_DOWN(offset); |
199 | offset >>= PAGE_SHIFT; | ||
200 | 209 | ||
201 | /* | 210 | /* |
202 | * We try to allocate bootmem pages above 'goal' | 211 | * We try to allocate bootmem pages above 'goal' |
203 | * first, then we try to allocate lower pages. | 212 | * first, then we try to allocate lower pages. |
204 | */ | 213 | */ |
205 | if (goal && (goal >= bdata->node_boot_start) && | 214 | if (goal && goal >= bdata->node_boot_start && PFN_DOWN(goal) < end_pfn) { |
206 | ((goal >> PAGE_SHIFT) < end_pfn)) { | ||
207 | preferred = goal - bdata->node_boot_start; | 215 | preferred = goal - bdata->node_boot_start; |
208 | 216 | ||
209 | if (bdata->last_success >= preferred) | 217 | if (bdata->last_success >= preferred) |
@@ -212,9 +220,8 @@ __alloc_bootmem_core(struct bootmem_data *bdata, unsigned long size, | |||
212 | } else | 220 | } else |
213 | preferred = 0; | 221 | preferred = 0; |
214 | 222 | ||
215 | preferred = ALIGN(preferred, align) >> PAGE_SHIFT; | 223 | preferred = PFN_DOWN(ALIGN(preferred, align)) + offset; |
216 | preferred += offset; | 224 | areasize = (size + PAGE_SIZE-1) / PAGE_SIZE; |
217 | areasize = (size+PAGE_SIZE-1)/PAGE_SIZE; | ||
218 | incr = align >> PAGE_SHIFT ? : 1; | 225 | incr = align >> PAGE_SHIFT ? : 1; |
219 | 226 | ||
220 | restart_scan: | 227 | restart_scan: |
@@ -229,7 +236,7 @@ restart_scan: | |||
229 | for (j = i + 1; j < i + areasize; ++j) { | 236 | for (j = i + 1; j < i + areasize; ++j) { |
230 | if (j >= eidx) | 237 | if (j >= eidx) |
231 | goto fail_block; | 238 | goto fail_block; |
232 | if (test_bit (j, bdata->node_bootmem_map)) | 239 | if (test_bit(j, bdata->node_bootmem_map)) |
233 | goto fail_block; | 240 | goto fail_block; |
234 | } | 241 | } |
235 | start = i; | 242 | start = i; |
@@ -245,7 +252,7 @@ restart_scan: | |||
245 | return NULL; | 252 | return NULL; |
246 | 253 | ||
247 | found: | 254 | found: |
248 | bdata->last_success = start << PAGE_SHIFT; | 255 | bdata->last_success = PFN_PHYS(start); |
249 | BUG_ON(start >= eidx); | 256 | BUG_ON(start >= eidx); |
250 | 257 | ||
251 | /* | 258 | /* |
@@ -257,19 +264,21 @@ found: | |||
257 | bdata->last_offset && bdata->last_pos+1 == start) { | 264 | bdata->last_offset && bdata->last_pos+1 == start) { |
258 | offset = ALIGN(bdata->last_offset, align); | 265 | offset = ALIGN(bdata->last_offset, align); |
259 | BUG_ON(offset > PAGE_SIZE); | 266 | BUG_ON(offset > PAGE_SIZE); |
260 | remaining_size = PAGE_SIZE-offset; | 267 | remaining_size = PAGE_SIZE - offset; |
261 | if (size < remaining_size) { | 268 | if (size < remaining_size) { |
262 | areasize = 0; | 269 | areasize = 0; |
263 | /* last_pos unchanged */ | 270 | /* last_pos unchanged */ |
264 | bdata->last_offset = offset+size; | 271 | bdata->last_offset = offset + size; |
265 | ret = phys_to_virt(bdata->last_pos*PAGE_SIZE + offset + | 272 | ret = phys_to_virt(bdata->last_pos * PAGE_SIZE + |
266 | bdata->node_boot_start); | 273 | offset + |
274 | bdata->node_boot_start); | ||
267 | } else { | 275 | } else { |
268 | remaining_size = size - remaining_size; | 276 | remaining_size = size - remaining_size; |
269 | areasize = (remaining_size+PAGE_SIZE-1)/PAGE_SIZE; | 277 | areasize = (remaining_size + PAGE_SIZE-1) / PAGE_SIZE; |
270 | ret = phys_to_virt(bdata->last_pos*PAGE_SIZE + offset + | 278 | ret = phys_to_virt(bdata->last_pos * PAGE_SIZE + |
271 | bdata->node_boot_start); | 279 | offset + |
272 | bdata->last_pos = start+areasize-1; | 280 | bdata->node_boot_start); |
281 | bdata->last_pos = start + areasize - 1; | ||
273 | bdata->last_offset = remaining_size; | 282 | bdata->last_offset = remaining_size; |
274 | } | 283 | } |
275 | bdata->last_offset &= ~PAGE_MASK; | 284 | bdata->last_offset &= ~PAGE_MASK; |
@@ -282,7 +291,7 @@ found: | |||
282 | /* | 291 | /* |
283 | * Reserve the area now: | 292 | * Reserve the area now: |
284 | */ | 293 | */ |
285 | for (i = start; i < start+areasize; i++) | 294 | for (i = start; i < start + areasize; i++) |
286 | if (unlikely(test_and_set_bit(i, bdata->node_bootmem_map))) | 295 | if (unlikely(test_and_set_bit(i, bdata->node_bootmem_map))) |
287 | BUG(); | 296 | BUG(); |
288 | memset(ret, 0, size); | 297 | memset(ret, 0, size); |
@@ -303,8 +312,8 @@ static unsigned long __init free_all_bootmem_core(pg_data_t *pgdat) | |||
303 | 312 | ||
304 | count = 0; | 313 | count = 0; |
305 | /* first extant page of the node */ | 314 | /* first extant page of the node */ |
306 | pfn = bdata->node_boot_start >> PAGE_SHIFT; | 315 | pfn = PFN_DOWN(bdata->node_boot_start); |
307 | idx = bdata->node_low_pfn - (bdata->node_boot_start >> PAGE_SHIFT); | 316 | idx = bdata->node_low_pfn - pfn; |
308 | map = bdata->node_bootmem_map; | 317 | map = bdata->node_bootmem_map; |
309 | /* Check physaddr is O(LOG2(BITS_PER_LONG)) page aligned */ | 318 | /* Check physaddr is O(LOG2(BITS_PER_LONG)) page aligned */ |
310 | if (bdata->node_boot_start == 0 || | 319 | if (bdata->node_boot_start == 0 || |
@@ -333,7 +342,7 @@ static unsigned long __init free_all_bootmem_core(pg_data_t *pgdat) | |||
333 | } | 342 | } |
334 | } | 343 | } |
335 | } else { | 344 | } else { |
336 | i+=BITS_PER_LONG; | 345 | i += BITS_PER_LONG; |
337 | } | 346 | } |
338 | pfn += BITS_PER_LONG; | 347 | pfn += BITS_PER_LONG; |
339 | } | 348 | } |
@@ -345,9 +354,10 @@ static unsigned long __init free_all_bootmem_core(pg_data_t *pgdat) | |||
345 | */ | 354 | */ |
346 | page = virt_to_page(bdata->node_bootmem_map); | 355 | page = virt_to_page(bdata->node_bootmem_map); |
347 | count = 0; | 356 | count = 0; |
348 | for (i = 0; i < ((bdata->node_low_pfn-(bdata->node_boot_start >> PAGE_SHIFT))/8 + PAGE_SIZE-1)/PAGE_SIZE; i++,page++) { | 357 | idx = (get_mapsize(bdata) + PAGE_SIZE-1) >> PAGE_SHIFT; |
349 | count++; | 358 | for (i = 0; i < idx; i++, page++) { |
350 | __free_pages_bootmem(page, 0); | 359 | __free_pages_bootmem(page, 0); |
360 | count++; | ||
351 | } | 361 | } |
352 | total += count; | 362 | total += count; |
353 | bdata->node_bootmem_map = NULL; | 363 | bdata->node_bootmem_map = NULL; |
@@ -355,64 +365,72 @@ static unsigned long __init free_all_bootmem_core(pg_data_t *pgdat) | |||
355 | return total; | 365 | return total; |
356 | } | 366 | } |
357 | 367 | ||
358 | unsigned long __init init_bootmem_node (pg_data_t *pgdat, unsigned long freepfn, unsigned long startpfn, unsigned long endpfn) | 368 | unsigned long __init init_bootmem_node(pg_data_t *pgdat, unsigned long freepfn, |
369 | unsigned long startpfn, unsigned long endpfn) | ||
359 | { | 370 | { |
360 | return(init_bootmem_core(pgdat, freepfn, startpfn, endpfn)); | 371 | return init_bootmem_core(pgdat, freepfn, startpfn, endpfn); |
361 | } | 372 | } |
362 | 373 | ||
363 | void __init reserve_bootmem_node (pg_data_t *pgdat, unsigned long physaddr, unsigned long size) | 374 | void __init reserve_bootmem_node(pg_data_t *pgdat, unsigned long physaddr, |
375 | unsigned long size) | ||
364 | { | 376 | { |
365 | reserve_bootmem_core(pgdat->bdata, physaddr, size); | 377 | reserve_bootmem_core(pgdat->bdata, physaddr, size); |
366 | } | 378 | } |
367 | 379 | ||
368 | void __init free_bootmem_node (pg_data_t *pgdat, unsigned long physaddr, unsigned long size) | 380 | void __init free_bootmem_node(pg_data_t *pgdat, unsigned long physaddr, |
381 | unsigned long size) | ||
369 | { | 382 | { |
370 | free_bootmem_core(pgdat->bdata, physaddr, size); | 383 | free_bootmem_core(pgdat->bdata, physaddr, size); |
371 | } | 384 | } |
372 | 385 | ||
373 | unsigned long __init free_all_bootmem_node (pg_data_t *pgdat) | 386 | unsigned long __init free_all_bootmem_node(pg_data_t *pgdat) |
374 | { | 387 | { |
375 | return(free_all_bootmem_core(pgdat)); | 388 | return free_all_bootmem_core(pgdat); |
376 | } | 389 | } |
377 | 390 | ||
378 | unsigned long __init init_bootmem (unsigned long start, unsigned long pages) | 391 | unsigned long __init init_bootmem(unsigned long start, unsigned long pages) |
379 | { | 392 | { |
380 | max_low_pfn = pages; | 393 | max_low_pfn = pages; |
381 | min_low_pfn = start; | 394 | min_low_pfn = start; |
382 | return(init_bootmem_core(NODE_DATA(0), start, 0, pages)); | 395 | return init_bootmem_core(NODE_DATA(0), start, 0, pages); |
383 | } | 396 | } |
384 | 397 | ||
385 | #ifndef CONFIG_HAVE_ARCH_BOOTMEM_NODE | 398 | #ifndef CONFIG_HAVE_ARCH_BOOTMEM_NODE |
386 | void __init reserve_bootmem (unsigned long addr, unsigned long size) | 399 | void __init reserve_bootmem(unsigned long addr, unsigned long size) |
387 | { | 400 | { |
388 | reserve_bootmem_core(NODE_DATA(0)->bdata, addr, size); | 401 | reserve_bootmem_core(NODE_DATA(0)->bdata, addr, size); |
389 | } | 402 | } |
390 | #endif /* !CONFIG_HAVE_ARCH_BOOTMEM_NODE */ | 403 | #endif /* !CONFIG_HAVE_ARCH_BOOTMEM_NODE */ |
391 | 404 | ||
392 | void __init free_bootmem (unsigned long addr, unsigned long size) | 405 | void __init free_bootmem(unsigned long addr, unsigned long size) |
393 | { | 406 | { |
394 | free_bootmem_core(NODE_DATA(0)->bdata, addr, size); | 407 | free_bootmem_core(NODE_DATA(0)->bdata, addr, size); |
395 | } | 408 | } |
396 | 409 | ||
397 | unsigned long __init free_all_bootmem (void) | 410 | unsigned long __init free_all_bootmem(void) |
398 | { | 411 | { |
399 | return(free_all_bootmem_core(NODE_DATA(0))); | 412 | return free_all_bootmem_core(NODE_DATA(0)); |
400 | } | 413 | } |
401 | 414 | ||
402 | void * __init __alloc_bootmem_nopanic(unsigned long size, unsigned long align, unsigned long goal) | 415 | void * __init __alloc_bootmem_nopanic(unsigned long size, unsigned long align, |
416 | unsigned long goal) | ||
403 | { | 417 | { |
404 | bootmem_data_t *bdata; | 418 | bootmem_data_t *bdata; |
405 | void *ptr; | 419 | void *ptr; |
406 | 420 | ||
407 | list_for_each_entry(bdata, &bdata_list, list) | 421 | list_for_each_entry(bdata, &bdata_list, list) { |
408 | if ((ptr = __alloc_bootmem_core(bdata, size, align, goal, 0))) | 422 | ptr = __alloc_bootmem_core(bdata, size, align, goal, 0); |
409 | return(ptr); | 423 | if (ptr) |
424 | return ptr; | ||
425 | } | ||
410 | return NULL; | 426 | return NULL; |
411 | } | 427 | } |
412 | 428 | ||
413 | void * __init __alloc_bootmem(unsigned long size, unsigned long align, unsigned long goal) | 429 | void * __init __alloc_bootmem(unsigned long size, unsigned long align, |
430 | unsigned long goal) | ||
414 | { | 431 | { |
415 | void *mem = __alloc_bootmem_nopanic(size,align,goal); | 432 | void *mem = __alloc_bootmem_nopanic(size,align,goal); |
433 | |||
416 | if (mem) | 434 | if (mem) |
417 | return mem; | 435 | return mem; |
418 | /* | 436 | /* |
@@ -424,29 +442,34 @@ void * __init __alloc_bootmem(unsigned long size, unsigned long align, unsigned | |||
424 | } | 442 | } |
425 | 443 | ||
426 | 444 | ||
427 | void * __init __alloc_bootmem_node(pg_data_t *pgdat, unsigned long size, unsigned long align, | 445 | void * __init __alloc_bootmem_node(pg_data_t *pgdat, unsigned long size, |
428 | unsigned long goal) | 446 | unsigned long align, unsigned long goal) |
429 | { | 447 | { |
430 | void *ptr; | 448 | void *ptr; |
431 | 449 | ||
432 | ptr = __alloc_bootmem_core(pgdat->bdata, size, align, goal, 0); | 450 | ptr = __alloc_bootmem_core(pgdat->bdata, size, align, goal, 0); |
433 | if (ptr) | 451 | if (ptr) |
434 | return (ptr); | 452 | return ptr; |
435 | 453 | ||
436 | return __alloc_bootmem(size, align, goal); | 454 | return __alloc_bootmem(size, align, goal); |
437 | } | 455 | } |
438 | 456 | ||
439 | #define LOW32LIMIT 0xffffffff | 457 | #ifndef ARCH_LOW_ADDRESS_LIMIT |
458 | #define ARCH_LOW_ADDRESS_LIMIT 0xffffffffUL | ||
459 | #endif | ||
440 | 460 | ||
441 | void * __init __alloc_bootmem_low(unsigned long size, unsigned long align, unsigned long goal) | 461 | void * __init __alloc_bootmem_low(unsigned long size, unsigned long align, |
462 | unsigned long goal) | ||
442 | { | 463 | { |
443 | bootmem_data_t *bdata; | 464 | bootmem_data_t *bdata; |
444 | void *ptr; | 465 | void *ptr; |
445 | 466 | ||
446 | list_for_each_entry(bdata, &bdata_list, list) | 467 | list_for_each_entry(bdata, &bdata_list, list) { |
447 | if ((ptr = __alloc_bootmem_core(bdata, size, | 468 | ptr = __alloc_bootmem_core(bdata, size, align, goal, |
448 | align, goal, LOW32LIMIT))) | 469 | ARCH_LOW_ADDRESS_LIMIT); |
449 | return(ptr); | 470 | if (ptr) |
471 | return ptr; | ||
472 | } | ||
450 | 473 | ||
451 | /* | 474 | /* |
452 | * Whoops, we cannot satisfy the allocation request. | 475 | * Whoops, we cannot satisfy the allocation request. |
@@ -459,5 +482,6 @@ void * __init __alloc_bootmem_low(unsigned long size, unsigned long align, unsig | |||
459 | void * __init __alloc_bootmem_low_node(pg_data_t *pgdat, unsigned long size, | 482 | void * __init __alloc_bootmem_low_node(pg_data_t *pgdat, unsigned long size, |
460 | unsigned long align, unsigned long goal) | 483 | unsigned long align, unsigned long goal) |
461 | { | 484 | { |
462 | return __alloc_bootmem_core(pgdat->bdata, size, align, goal, LOW32LIMIT); | 485 | return __alloc_bootmem_core(pgdat->bdata, size, align, goal, |
486 | ARCH_LOW_ADDRESS_LIMIT); | ||
463 | } | 487 | } |