2 * bootmem - A boot-time physical memory allocator and configurator
4 * Copyright (C) 1999 Ingo Molnar
5 * 1999 Kanoj Sarcar, SGI
8 * Access to this subsystem has to be serialized externally (which is true
9 * for the boot process anyway).
11 #include <linux/init.h>
12 #include <linux/pfn.h>
13 #include <linux/slab.h>
14 #include <linux/bootmem.h>
15 #include <linux/module.h>
16 #include <linux/kmemleak.h>
17 #include <linux/range.h>
21 #include <asm/processor.h>
25 unsigned long max_low_pfn;
26 unsigned long min_low_pfn;
27 unsigned long max_pfn;
29 #ifdef CONFIG_CRASH_DUMP
31 * If we have booted due to a crash, max_pfn will be a very low value. We need
32 * to know the amount of memory that the previous kernel used.
34 unsigned long saved_max_pfn;
37 #ifndef CONFIG_NO_BOOTMEM
38 bootmem_data_t bootmem_node_data[MAX_NUMNODES] __initdata;
40 static struct list_head bdata_list __initdata = LIST_HEAD_INIT(bdata_list);
42 static int bootmem_debug;
44 static int __init bootmem_debug_setup(char *buf)
49 early_param("bootmem_debug", bootmem_debug_setup);
51 #define bdebug(fmt, args...) ({ \
52 if (unlikely(bootmem_debug)) \
58 static unsigned long __init bootmap_bytes(unsigned long pages)
60 unsigned long bytes = (pages + 7) / 8;
62 return ALIGN(bytes, sizeof(long));
66 * bootmem_bootmap_pages - calculate bitmap size in pages
67 * @pages: number of pages the bitmap has to represent
69 unsigned long __init bootmem_bootmap_pages(unsigned long pages)
71 unsigned long bytes = bootmap_bytes(pages);
73 return PAGE_ALIGN(bytes) >> PAGE_SHIFT;
79 static void __init link_bootmem(bootmem_data_t *bdata)
81 struct list_head *iter;
83 list_for_each(iter, &bdata_list) {
86 ent = list_entry(iter, bootmem_data_t, list);
87 if (bdata->node_min_pfn < ent->node_min_pfn)
90 list_add_tail(&bdata->list, iter);
94 * Called once to set up the allocator itself.
96 static unsigned long __init init_bootmem_core(bootmem_data_t *bdata,
97 unsigned long mapstart, unsigned long start, unsigned long end)
99 unsigned long mapsize;
101 mminit_validate_memmodel_limits(&start, &end);
102 bdata->node_bootmem_map = phys_to_virt(PFN_PHYS(mapstart));
103 bdata->node_min_pfn = start;
104 bdata->node_low_pfn = end;
108 * Initially all pages are reserved - setup_arch() has to
109 * register free RAM areas explicitly.
111 mapsize = bootmap_bytes(end - start);
112 memset(bdata->node_bootmem_map, 0xff, mapsize);
114 bdebug("nid=%td start=%lx map=%lx end=%lx mapsize=%lx\n",
115 bdata - bootmem_node_data, start, mapstart, end, mapsize);
121 * init_bootmem_node - register a node as boot memory
122 * @pgdat: node to register
123 * @freepfn: pfn where the bitmap for this node is to be placed
124 * @startpfn: first pfn on the node
125 * @endpfn: first pfn after the node
127 * Returns the number of bytes needed to hold the bitmap for this node.
129 unsigned long __init init_bootmem_node(pg_data_t *pgdat, unsigned long freepfn,
130 unsigned long startpfn, unsigned long endpfn)
132 return init_bootmem_core(pgdat->bdata, freepfn, startpfn, endpfn);
136 * init_bootmem - register boot memory
137 * @start: pfn where the bitmap is to be placed
138 * @pages: number of available physical pages
140 * Returns the number of bytes needed to hold the bitmap.
142 unsigned long __init init_bootmem(unsigned long start, unsigned long pages)
146 return init_bootmem_core(NODE_DATA(0)->bdata, start, 0, pages);
150 * free_bootmem_late - free bootmem pages directly to page allocator
151 * @addr: starting address of the range
152 * @size: size of the range in bytes
154 * This is only useful when the bootmem allocator has already been torn
155 * down, but we are still initializing the system. Pages are given directly
156 * to the page allocator, no bootmem metadata is updated because it is gone.
158 void __init free_bootmem_late(unsigned long addr, unsigned long size)
160 unsigned long cursor, end;
162 kmemleak_free_part(__va(addr), size);
164 cursor = PFN_UP(addr);
165 end = PFN_DOWN(addr + size);
167 for (; cursor < end; cursor++) {
168 __free_pages_bootmem(pfn_to_page(cursor), 0);
173 #ifdef CONFIG_NO_BOOTMEM
174 static void __init __free_pages_memory(unsigned long start, unsigned long end)
177 unsigned long start_aligned, end_aligned;
178 int order = ilog2(BITS_PER_LONG);
180 start_aligned = (start + (BITS_PER_LONG - 1)) & ~(BITS_PER_LONG - 1);
181 end_aligned = end & ~(BITS_PER_LONG - 1);
183 if (end_aligned <= start_aligned) {
184 for (i = start; i < end; i++)
185 __free_pages_bootmem(pfn_to_page(i), 0);
190 for (i = start; i < start_aligned; i++)
191 __free_pages_bootmem(pfn_to_page(i), 0);
193 for (i = start_aligned; i < end_aligned; i += BITS_PER_LONG)
194 __free_pages_bootmem(pfn_to_page(i), order);
196 for (i = end_aligned; i < end; i++)
197 __free_pages_bootmem(pfn_to_page(i), 0);
200 unsigned long __init free_all_memory_core_early(int nodeid)
204 unsigned long count = 0;
205 struct range *range = NULL;
208 nr_range = get_free_all_memory_range(&range, nodeid);
210 for (i = 0; i < nr_range; i++) {
211 start = range[i].start;
213 count += end - start;
214 __free_pages_memory(start, end);
220 static unsigned long __init free_all_bootmem_core(bootmem_data_t *bdata)
224 unsigned long start, end, pages, count = 0;
226 if (!bdata->node_bootmem_map)
229 start = bdata->node_min_pfn;
230 end = bdata->node_low_pfn;
233 * If the start is aligned to the machines wordsize, we might
234 * be able to free pages in bulks of that order.
236 aligned = !(start & (BITS_PER_LONG - 1));
238 bdebug("nid=%td start=%lx end=%lx aligned=%d\n",
239 bdata - bootmem_node_data, start, end, aligned);
241 while (start < end) {
242 unsigned long *map, idx, vec;
244 map = bdata->node_bootmem_map;
245 idx = start - bdata->node_min_pfn;
246 vec = ~map[idx / BITS_PER_LONG];
248 if (aligned && vec == ~0UL && start + BITS_PER_LONG < end) {
249 int order = ilog2(BITS_PER_LONG);
251 __free_pages_bootmem(pfn_to_page(start), order);
252 count += BITS_PER_LONG;
254 unsigned long off = 0;
256 while (vec && off < BITS_PER_LONG) {
258 page = pfn_to_page(start + off);
259 __free_pages_bootmem(page, 0);
266 start += BITS_PER_LONG;
269 page = virt_to_page(bdata->node_bootmem_map);
270 pages = bdata->node_low_pfn - bdata->node_min_pfn;
271 pages = bootmem_bootmap_pages(pages);
274 __free_pages_bootmem(page++, 0);
276 bdebug("nid=%td released=%lx\n", bdata - bootmem_node_data, count);
283 * free_all_bootmem_node - release a node's free pages to the buddy allocator
284 * @pgdat: node to be released
286 * Returns the number of pages actually released.
288 unsigned long __init free_all_bootmem_node(pg_data_t *pgdat)
290 register_page_bootmem_info_node(pgdat);
291 #ifdef CONFIG_NO_BOOTMEM
292 /* free_all_memory_core_early(MAX_NUMNODES) will be called later */
295 return free_all_bootmem_core(pgdat->bdata);
300 * free_all_bootmem - release free pages to the buddy allocator
302 * Returns the number of pages actually released.
304 unsigned long __init free_all_bootmem(void)
306 #ifdef CONFIG_NO_BOOTMEM
308 * We need to use MAX_NUMNODES instead of NODE_DATA(0)->node_id
309 * because in some case like Node0 doesnt have RAM installed
310 * low ram will be on Node1
311 * Use MAX_NUMNODES will make sure all ranges in early_node_map[]
312 * will be used instead of only Node0 related
314 return free_all_memory_core_early(MAX_NUMNODES);
316 unsigned long total_pages = 0;
317 bootmem_data_t *bdata;
319 list_for_each_entry(bdata, &bdata_list, list)
320 total_pages += free_all_bootmem_core(bdata);
326 #ifndef CONFIG_NO_BOOTMEM
327 static void __init __free(bootmem_data_t *bdata,
328 unsigned long sidx, unsigned long eidx)
332 bdebug("nid=%td start=%lx end=%lx\n", bdata - bootmem_node_data,
333 sidx + bdata->node_min_pfn,
334 eidx + bdata->node_min_pfn);
336 if (bdata->hint_idx > sidx)
337 bdata->hint_idx = sidx;
339 for (idx = sidx; idx < eidx; idx++)
340 if (!test_and_clear_bit(idx, bdata->node_bootmem_map))
344 static int __init __reserve(bootmem_data_t *bdata, unsigned long sidx,
345 unsigned long eidx, int flags)
348 int exclusive = flags & BOOTMEM_EXCLUSIVE;
350 bdebug("nid=%td start=%lx end=%lx flags=%x\n",
351 bdata - bootmem_node_data,
352 sidx + bdata->node_min_pfn,
353 eidx + bdata->node_min_pfn,
356 for (idx = sidx; idx < eidx; idx++)
357 if (test_and_set_bit(idx, bdata->node_bootmem_map)) {
359 __free(bdata, sidx, idx);
362 bdebug("silent double reserve of PFN %lx\n",
363 idx + bdata->node_min_pfn);
368 static int __init mark_bootmem_node(bootmem_data_t *bdata,
369 unsigned long start, unsigned long end,
370 int reserve, int flags)
372 unsigned long sidx, eidx;
374 bdebug("nid=%td start=%lx end=%lx reserve=%d flags=%x\n",
375 bdata - bootmem_node_data, start, end, reserve, flags);
377 BUG_ON(start < bdata->node_min_pfn);
378 BUG_ON(end > bdata->node_low_pfn);
380 sidx = start - bdata->node_min_pfn;
381 eidx = end - bdata->node_min_pfn;
384 return __reserve(bdata, sidx, eidx, flags);
386 __free(bdata, sidx, eidx);
390 static int __init mark_bootmem(unsigned long start, unsigned long end,
391 int reserve, int flags)
394 bootmem_data_t *bdata;
397 list_for_each_entry(bdata, &bdata_list, list) {
401 if (pos < bdata->node_min_pfn ||
402 pos >= bdata->node_low_pfn) {
403 BUG_ON(pos != start);
407 max = min(bdata->node_low_pfn, end);
409 err = mark_bootmem_node(bdata, pos, max, reserve, flags);
410 if (reserve && err) {
411 mark_bootmem(start, pos, 0, 0);
417 pos = bdata->node_low_pfn;
424 * free_bootmem_node - mark a page range as usable
425 * @pgdat: node the range resides on
426 * @physaddr: starting address of the range
427 * @size: size of the range in bytes
429 * Partial pages will be considered reserved and left as they are.
431 * The range must reside completely on the specified node.
433 void __init free_bootmem_node(pg_data_t *pgdat, unsigned long physaddr,
436 #ifdef CONFIG_NO_BOOTMEM
437 free_early(physaddr, physaddr + size);
439 unsigned long start, end;
441 kmemleak_free_part(__va(physaddr), size);
443 start = PFN_UP(physaddr);
444 end = PFN_DOWN(physaddr + size);
446 mark_bootmem_node(pgdat->bdata, start, end, 0, 0);
451 * free_bootmem - mark a page range as usable
452 * @addr: starting address of the range
453 * @size: size of the range in bytes
455 * Partial pages will be considered reserved and left as they are.
457 * The range must be contiguous but may span node boundaries.
459 void __init free_bootmem(unsigned long addr, unsigned long size)
461 #ifdef CONFIG_NO_BOOTMEM
462 free_early(addr, addr + size);
464 unsigned long start, end;
466 kmemleak_free_part(__va(addr), size);
468 start = PFN_UP(addr);
469 end = PFN_DOWN(addr + size);
471 mark_bootmem(start, end, 0, 0);
476 * reserve_bootmem_node - mark a page range as reserved
477 * @pgdat: node the range resides on
478 * @physaddr: starting address of the range
479 * @size: size of the range in bytes
480 * @flags: reservation flags (see linux/bootmem.h)
482 * Partial pages will be reserved.
484 * The range must reside completely on the specified node.
486 int __init reserve_bootmem_node(pg_data_t *pgdat, unsigned long physaddr,
487 unsigned long size, int flags)
489 #ifdef CONFIG_NO_BOOTMEM
493 unsigned long start, end;
495 start = PFN_DOWN(physaddr);
496 end = PFN_UP(physaddr + size);
498 return mark_bootmem_node(pgdat->bdata, start, end, 1, flags);
503 * reserve_bootmem - mark a page range as usable
504 * @addr: starting address of the range
505 * @size: size of the range in bytes
506 * @flags: reservation flags (see linux/bootmem.h)
508 * Partial pages will be reserved.
510 * The range must be contiguous but may span node boundaries.
512 int __init reserve_bootmem(unsigned long addr, unsigned long size,
515 #ifdef CONFIG_NO_BOOTMEM
519 unsigned long start, end;
521 start = PFN_DOWN(addr);
522 end = PFN_UP(addr + size);
524 return mark_bootmem(start, end, 1, flags);
528 #ifndef CONFIG_NO_BOOTMEM
529 int __weak __init reserve_bootmem_generic(unsigned long phys, unsigned long len,
532 return reserve_bootmem(phys, len, flags);
535 static unsigned long __init align_idx(struct bootmem_data *bdata,
536 unsigned long idx, unsigned long step)
538 unsigned long base = bdata->node_min_pfn;
541 * Align the index with respect to the node start so that the
542 * combination of both satisfies the requested alignment.
545 return ALIGN(base + idx, step) - base;
548 static unsigned long __init align_off(struct bootmem_data *bdata,
549 unsigned long off, unsigned long align)
551 unsigned long base = PFN_PHYS(bdata->node_min_pfn);
553 /* Same as align_idx for byte offsets */
555 return ALIGN(base + off, align) - base;
558 static void * __init alloc_bootmem_core(struct bootmem_data *bdata,
559 unsigned long size, unsigned long align,
560 unsigned long goal, unsigned long limit)
562 unsigned long fallback = 0;
563 unsigned long min, max, start, sidx, midx, step;
565 bdebug("nid=%td size=%lx [%lu pages] align=%lx goal=%lx limit=%lx\n",
566 bdata - bootmem_node_data, size, PAGE_ALIGN(size) >> PAGE_SHIFT,
570 BUG_ON(align & (align - 1));
571 BUG_ON(limit && goal + size > limit);
573 if (!bdata->node_bootmem_map)
576 min = bdata->node_min_pfn;
577 max = bdata->node_low_pfn;
580 limit >>= PAGE_SHIFT;
582 if (limit && max > limit)
587 step = max(align >> PAGE_SHIFT, 1UL);
589 if (goal && min < goal && goal < max)
590 start = ALIGN(goal, step);
592 start = ALIGN(min, step);
594 sidx = start - bdata->node_min_pfn;
595 midx = max - bdata->node_min_pfn;
597 if (bdata->hint_idx > sidx) {
599 * Handle the valid case of sidx being zero and still
600 * catch the fallback below.
603 sidx = align_idx(bdata, bdata->hint_idx, step);
609 unsigned long eidx, i, start_off, end_off;
611 sidx = find_next_zero_bit(bdata->node_bootmem_map, midx, sidx);
612 sidx = align_idx(bdata, sidx, step);
613 eidx = sidx + PFN_UP(size);
615 if (sidx >= midx || eidx > midx)
618 for (i = sidx; i < eidx; i++)
619 if (test_bit(i, bdata->node_bootmem_map)) {
620 sidx = align_idx(bdata, i, step);
626 if (bdata->last_end_off & (PAGE_SIZE - 1) &&
627 PFN_DOWN(bdata->last_end_off) + 1 == sidx)
628 start_off = align_off(bdata, bdata->last_end_off, align);
630 start_off = PFN_PHYS(sidx);
632 merge = PFN_DOWN(start_off) < sidx;
633 end_off = start_off + size;
635 bdata->last_end_off = end_off;
636 bdata->hint_idx = PFN_UP(end_off);
639 * Reserve the area now:
641 if (__reserve(bdata, PFN_DOWN(start_off) + merge,
642 PFN_UP(end_off), BOOTMEM_EXCLUSIVE))
645 region = phys_to_virt(PFN_PHYS(bdata->node_min_pfn) +
647 memset(region, 0, size);
649 * The min_count is set to 0 so that bootmem allocated blocks
650 * are never reported as leaks.
652 kmemleak_alloc(region, size, 0, 0);
657 sidx = align_idx(bdata, fallback - 1, step);
665 static void * __init alloc_arch_preferred_bootmem(bootmem_data_t *bdata,
666 unsigned long size, unsigned long align,
667 unsigned long goal, unsigned long limit)
669 if (WARN_ON_ONCE(slab_is_available()))
670 return kzalloc(size, GFP_NOWAIT);
672 #ifdef CONFIG_HAVE_ARCH_BOOTMEM
674 bootmem_data_t *p_bdata;
676 p_bdata = bootmem_arch_preferred_node(bdata, size, align,
679 return alloc_bootmem_core(p_bdata, size, align,
687 static void * __init ___alloc_bootmem_nopanic(unsigned long size,
692 #ifdef CONFIG_NO_BOOTMEM
695 if (WARN_ON_ONCE(slab_is_available()))
696 return kzalloc(size, GFP_NOWAIT);
700 ptr = __alloc_memory_core_early(MAX_NUMNODES, size, align, goal, limit);
712 bootmem_data_t *bdata;
716 region = alloc_arch_preferred_bootmem(NULL, size, align, goal, limit);
720 list_for_each_entry(bdata, &bdata_list, list) {
721 if (goal && bdata->node_low_pfn <= PFN_DOWN(goal))
723 if (limit && bdata->node_min_pfn >= PFN_DOWN(limit))
726 region = alloc_bootmem_core(bdata, size, align, goal, limit);
741 * __alloc_bootmem_nopanic - allocate boot memory without panicking
742 * @size: size of the request in bytes
743 * @align: alignment of the region
744 * @goal: preferred starting address of the region
746 * The goal is dropped if it can not be satisfied and the allocation will
747 * fall back to memory below @goal.
749 * Allocation may happen on any node in the system.
751 * Returns NULL on failure.
753 void * __init __alloc_bootmem_nopanic(unsigned long size, unsigned long align,
756 unsigned long limit = 0;
758 #ifdef CONFIG_NO_BOOTMEM
762 return ___alloc_bootmem_nopanic(size, align, goal, limit);
765 static void * __init ___alloc_bootmem(unsigned long size, unsigned long align,
766 unsigned long goal, unsigned long limit)
768 void *mem = ___alloc_bootmem_nopanic(size, align, goal, limit);
773 * Whoops, we cannot satisfy the allocation request.
775 printk(KERN_ALERT "bootmem alloc of %lu bytes failed!\n", size);
776 panic("Out of memory");
781 * __alloc_bootmem - allocate boot memory
782 * @size: size of the request in bytes
783 * @align: alignment of the region
784 * @goal: preferred starting address of the region
786 * The goal is dropped if it can not be satisfied and the allocation will
787 * fall back to memory below @goal.
789 * Allocation may happen on any node in the system.
791 * The function panics if the request can not be satisfied.
793 void * __init __alloc_bootmem(unsigned long size, unsigned long align,
796 unsigned long limit = 0;
798 #ifdef CONFIG_NO_BOOTMEM
802 return ___alloc_bootmem(size, align, goal, limit);
805 #ifndef CONFIG_NO_BOOTMEM
806 static void * __init ___alloc_bootmem_node(bootmem_data_t *bdata,
807 unsigned long size, unsigned long align,
808 unsigned long goal, unsigned long limit)
812 ptr = alloc_arch_preferred_bootmem(bdata, size, align, goal, limit);
816 ptr = alloc_bootmem_core(bdata, size, align, goal, limit);
820 return ___alloc_bootmem(size, align, goal, limit);
825 * __alloc_bootmem_node - allocate boot memory from a specific node
826 * @pgdat: node to allocate from
827 * @size: size of the request in bytes
828 * @align: alignment of the region
829 * @goal: preferred starting address of the region
831 * The goal is dropped if it can not be satisfied and the allocation will
832 * fall back to memory below @goal.
834 * Allocation may fall back to any node in the system if the specified node
835 * can not hold the requested memory.
837 * The function panics if the request can not be satisfied.
839 void * __init __alloc_bootmem_node(pg_data_t *pgdat, unsigned long size,
840 unsigned long align, unsigned long goal)
844 if (WARN_ON_ONCE(slab_is_available()))
845 return kzalloc_node(size, GFP_NOWAIT, pgdat->node_id);
847 #ifdef CONFIG_NO_BOOTMEM
848 ptr = __alloc_memory_core_early(pgdat->node_id, size, align,
853 ptr = __alloc_memory_core_early(MAX_NUMNODES, size, align,
856 ptr = ___alloc_bootmem_node(pgdat->bdata, size, align, goal, 0);
862 void * __init __alloc_bootmem_node_high(pg_data_t *pgdat, unsigned long size,
863 unsigned long align, unsigned long goal)
866 unsigned long end_pfn;
868 if (WARN_ON_ONCE(slab_is_available()))
869 return kzalloc_node(size, GFP_NOWAIT, pgdat->node_id);
871 /* update goal according ...MAX_DMA32_PFN */
872 end_pfn = pgdat->node_start_pfn + pgdat->node_spanned_pages;
874 if (end_pfn > MAX_DMA32_PFN + (128 >> (20 - PAGE_SHIFT)) &&
875 (goal >> PAGE_SHIFT) < MAX_DMA32_PFN) {
877 unsigned long new_goal;
879 new_goal = MAX_DMA32_PFN << PAGE_SHIFT;
880 #ifdef CONFIG_NO_BOOTMEM
881 ptr = __alloc_memory_core_early(pgdat->node_id, size, align,
884 ptr = alloc_bootmem_core(pgdat->bdata, size, align,
892 return __alloc_bootmem_node(pgdat, size, align, goal);
896 #ifdef CONFIG_SPARSEMEM
898 * alloc_bootmem_section - allocate boot memory from a specific section
899 * @size: size of the request in bytes
900 * @section_nr: sparse map section to allocate from
902 * Return NULL on failure.
904 void * __init alloc_bootmem_section(unsigned long size,
905 unsigned long section_nr)
907 #ifdef CONFIG_NO_BOOTMEM
908 unsigned long pfn, goal, limit;
910 pfn = section_nr_to_pfn(section_nr);
911 goal = pfn << PAGE_SHIFT;
912 limit = section_nr_to_pfn(section_nr + 1) << PAGE_SHIFT;
914 return __alloc_memory_core_early(early_pfn_to_nid(pfn), size,
915 SMP_CACHE_BYTES, goal, limit);
917 bootmem_data_t *bdata;
918 unsigned long pfn, goal, limit;
920 pfn = section_nr_to_pfn(section_nr);
921 goal = pfn << PAGE_SHIFT;
922 limit = section_nr_to_pfn(section_nr + 1) << PAGE_SHIFT;
923 bdata = &bootmem_node_data[early_pfn_to_nid(pfn)];
925 return alloc_bootmem_core(bdata, size, SMP_CACHE_BYTES, goal, limit);
930 void * __init __alloc_bootmem_node_nopanic(pg_data_t *pgdat, unsigned long size,
931 unsigned long align, unsigned long goal)
935 if (WARN_ON_ONCE(slab_is_available()))
936 return kzalloc_node(size, GFP_NOWAIT, pgdat->node_id);
938 #ifdef CONFIG_NO_BOOTMEM
939 ptr = __alloc_memory_core_early(pgdat->node_id, size, align,
942 ptr = alloc_arch_preferred_bootmem(pgdat->bdata, size, align, goal, 0);
946 ptr = alloc_bootmem_core(pgdat->bdata, size, align, goal, 0);
951 return __alloc_bootmem_nopanic(size, align, goal);
954 #ifndef ARCH_LOW_ADDRESS_LIMIT
955 #define ARCH_LOW_ADDRESS_LIMIT 0xffffffffUL
959 * __alloc_bootmem_low - allocate low boot memory
960 * @size: size of the request in bytes
961 * @align: alignment of the region
962 * @goal: preferred starting address of the region
964 * The goal is dropped if it can not be satisfied and the allocation will
965 * fall back to memory below @goal.
967 * Allocation may happen on any node in the system.
969 * The function panics if the request can not be satisfied.
971 void * __init __alloc_bootmem_low(unsigned long size, unsigned long align,
974 return ___alloc_bootmem(size, align, goal, ARCH_LOW_ADDRESS_LIMIT);
978 * __alloc_bootmem_low_node - allocate low boot memory from a specific node
979 * @pgdat: node to allocate from
980 * @size: size of the request in bytes
981 * @align: alignment of the region
982 * @goal: preferred starting address of the region
984 * The goal is dropped if it can not be satisfied and the allocation will
985 * fall back to memory below @goal.
987 * Allocation may fall back to any node in the system if the specified node
988 * can not hold the requested memory.
990 * The function panics if the request can not be satisfied.
992 void * __init __alloc_bootmem_low_node(pg_data_t *pgdat, unsigned long size,
993 unsigned long align, unsigned long goal)
997 if (WARN_ON_ONCE(slab_is_available()))
998 return kzalloc_node(size, GFP_NOWAIT, pgdat->node_id);
1000 #ifdef CONFIG_NO_BOOTMEM
1001 ptr = __alloc_memory_core_early(pgdat->node_id, size, align,
1002 goal, ARCH_LOW_ADDRESS_LIMIT);
1005 ptr = __alloc_memory_core_early(MAX_NUMNODES, size, align,
1006 goal, ARCH_LOW_ADDRESS_LIMIT);
1008 ptr = ___alloc_bootmem_node(pgdat->bdata, size, align,
1009 goal, ARCH_LOW_ADDRESS_LIMIT);