bootmem.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735
  1. /*
  2. * bootmem - A boot-time physical memory allocator and configurator
  3. *
  4. * Copyright (C) 1999 Ingo Molnar
  5. * 1999 Kanoj Sarcar, SGI
  6. * 2008 Johannes Weiner
  7. *
  8. * Access to this subsystem has to be serialized externally (which is true
  9. * for the boot process anyway).
  10. */
  11. #include <linux/init.h>
  12. #include <linux/pfn.h>
  13. #include <linux/bootmem.h>
  14. #include <linux/module.h>
  15. #include <asm/bug.h>
  16. #include <asm/io.h>
  17. #include <asm/processor.h>
  18. #include "internal.h"
  19. unsigned long max_low_pfn;
  20. unsigned long min_low_pfn;
  21. unsigned long max_pfn;
  22. #ifdef CONFIG_CRASH_DUMP
  23. /*
  24. * If we have booted due to a crash, max_pfn will be a very low value. We need
  25. * to know the amount of memory that the previous kernel used.
  26. */
  27. unsigned long saved_max_pfn;
  28. #endif
  29. bootmem_data_t bootmem_node_data[MAX_NUMNODES] __initdata;
  30. static struct list_head bdata_list __initdata = LIST_HEAD_INIT(bdata_list);
  31. static int bootmem_debug;
  32. /*
  33. * If an arch needs to apply workarounds to bootmem allocation, it can
  34. * set CONFIG_HAVE_ARCH_BOOTMEM and define a wrapper around
  35. * __alloc_bootmem_core().
  36. */
  37. #ifndef CONFIG_HAVE_ARCH_BOOTMEM
  38. #define alloc_bootmem_core(bdata, size, align, goal, limit) \
  39. __alloc_bootmem_core((bdata), (size), (align), (goal), (limit))
  40. #endif
  41. static int __init bootmem_debug_setup(char *buf)
  42. {
  43. bootmem_debug = 1;
  44. return 0;
  45. }
  46. early_param("bootmem_debug", bootmem_debug_setup);
  47. #define bdebug(fmt, args...) ({ \
  48. if (unlikely(bootmem_debug)) \
  49. printk(KERN_INFO \
  50. "bootmem::%s " fmt, \
  51. __func__, ## args); \
  52. })
  53. static unsigned long __init bootmap_bytes(unsigned long pages)
  54. {
  55. unsigned long bytes = (pages + 7) / 8;
  56. return ALIGN(bytes, sizeof(long));
  57. }
  58. /**
  59. * bootmem_bootmap_pages - calculate bitmap size in pages
  60. * @pages: number of pages the bitmap has to represent
  61. */
  62. unsigned long __init bootmem_bootmap_pages(unsigned long pages)
  63. {
  64. unsigned long bytes = bootmap_bytes(pages);
  65. return PAGE_ALIGN(bytes) >> PAGE_SHIFT;
  66. }
  67. /*
  68. * link bdata in order
  69. */
  70. static void __init link_bootmem(bootmem_data_t *bdata)
  71. {
  72. struct list_head *iter;
  73. list_for_each(iter, &bdata_list) {
  74. bootmem_data_t *ent;
  75. ent = list_entry(iter, bootmem_data_t, list);
  76. if (bdata->node_min_pfn < ent->node_min_pfn)
  77. break;
  78. }
  79. list_add_tail(&bdata->list, iter);
  80. }
  81. /*
  82. * Called once to set up the allocator itself.
  83. */
  84. static unsigned long __init init_bootmem_core(bootmem_data_t *bdata,
  85. unsigned long mapstart, unsigned long start, unsigned long end)
  86. {
  87. unsigned long mapsize;
  88. mminit_validate_memmodel_limits(&start, &end);
  89. bdata->node_bootmem_map = phys_to_virt(PFN_PHYS(mapstart));
  90. bdata->node_min_pfn = start;
  91. bdata->node_low_pfn = end;
  92. link_bootmem(bdata);
  93. /*
  94. * Initially all pages are reserved - setup_arch() has to
  95. * register free RAM areas explicitly.
  96. */
  97. mapsize = bootmap_bytes(end - start);
  98. memset(bdata->node_bootmem_map, 0xff, mapsize);
  99. bdebug("nid=%td start=%lx map=%lx end=%lx mapsize=%lx\n",
  100. bdata - bootmem_node_data, start, mapstart, end, mapsize);
  101. return mapsize;
  102. }
  103. /**
  104. * init_bootmem_node - register a node as boot memory
  105. * @pgdat: node to register
  106. * @freepfn: pfn where the bitmap for this node is to be placed
  107. * @startpfn: first pfn on the node
  108. * @endpfn: first pfn after the node
  109. *
  110. * Returns the number of bytes needed to hold the bitmap for this node.
  111. */
  112. unsigned long __init init_bootmem_node(pg_data_t *pgdat, unsigned long freepfn,
  113. unsigned long startpfn, unsigned long endpfn)
  114. {
  115. return init_bootmem_core(pgdat->bdata, freepfn, startpfn, endpfn);
  116. }
  117. /**
  118. * init_bootmem - register boot memory
  119. * @start: pfn where the bitmap is to be placed
  120. * @pages: number of available physical pages
  121. *
  122. * Returns the number of bytes needed to hold the bitmap.
  123. */
  124. unsigned long __init init_bootmem(unsigned long start, unsigned long pages)
  125. {
  126. max_low_pfn = pages;
  127. min_low_pfn = start;
  128. return init_bootmem_core(NODE_DATA(0)->bdata, start, 0, pages);
  129. }
  130. static unsigned long __init free_all_bootmem_core(bootmem_data_t *bdata)
  131. {
  132. int aligned;
  133. struct page *page;
  134. unsigned long start, end, pages, count = 0;
  135. if (!bdata->node_bootmem_map)
  136. return 0;
  137. start = bdata->node_min_pfn;
  138. end = bdata->node_low_pfn;
  139. /*
  140. * If the start is aligned to the machines wordsize, we might
  141. * be able to free pages in bulks of that order.
  142. */
  143. aligned = !(start & (BITS_PER_LONG - 1));
  144. bdebug("nid=%td start=%lx end=%lx aligned=%d\n",
  145. bdata - bootmem_node_data, start, end, aligned);
  146. while (start < end) {
  147. unsigned long *map, idx, vec;
  148. map = bdata->node_bootmem_map;
  149. idx = start - bdata->node_min_pfn;
  150. vec = ~map[idx / BITS_PER_LONG];
  151. if (aligned && vec == ~0UL && start + BITS_PER_LONG < end) {
  152. int order = ilog2(BITS_PER_LONG);
  153. __free_pages_bootmem(pfn_to_page(start), order);
  154. count += BITS_PER_LONG;
  155. } else {
  156. unsigned long off = 0;
  157. while (vec && off < BITS_PER_LONG) {
  158. if (vec & 1) {
  159. page = pfn_to_page(start + off);
  160. __free_pages_bootmem(page, 0);
  161. count++;
  162. }
  163. vec >>= 1;
  164. off++;
  165. }
  166. }
  167. start += BITS_PER_LONG;
  168. }
  169. page = virt_to_page(bdata->node_bootmem_map);
  170. pages = bdata->node_low_pfn - bdata->node_min_pfn;
  171. pages = bootmem_bootmap_pages(pages);
  172. count += pages;
  173. while (pages--)
  174. __free_pages_bootmem(page++, 0);
  175. bdebug("nid=%td released=%lx\n", bdata - bootmem_node_data, count);
  176. return count;
  177. }
  178. /**
  179. * free_all_bootmem_node - release a node's free pages to the buddy allocator
  180. * @pgdat: node to be released
  181. *
  182. * Returns the number of pages actually released.
  183. */
  184. unsigned long __init free_all_bootmem_node(pg_data_t *pgdat)
  185. {
  186. register_page_bootmem_info_node(pgdat);
  187. return free_all_bootmem_core(pgdat->bdata);
  188. }
  189. /**
  190. * free_all_bootmem - release free pages to the buddy allocator
  191. *
  192. * Returns the number of pages actually released.
  193. */
  194. unsigned long __init free_all_bootmem(void)
  195. {
  196. return free_all_bootmem_core(NODE_DATA(0)->bdata);
  197. }
  198. static void __init __free(bootmem_data_t *bdata,
  199. unsigned long sidx, unsigned long eidx)
  200. {
  201. unsigned long idx;
  202. bdebug("nid=%td start=%lx end=%lx\n", bdata - bootmem_node_data,
  203. sidx + bdata->node_min_pfn,
  204. eidx + bdata->node_min_pfn);
  205. if (bdata->hint_idx > sidx)
  206. bdata->hint_idx = sidx;
  207. for (idx = sidx; idx < eidx; idx++)
  208. if (!test_and_clear_bit(idx, bdata->node_bootmem_map))
  209. BUG();
  210. }
  211. static int __init __reserve(bootmem_data_t *bdata, unsigned long sidx,
  212. unsigned long eidx, int flags)
  213. {
  214. unsigned long idx;
  215. int exclusive = flags & BOOTMEM_EXCLUSIVE;
  216. bdebug("nid=%td start=%lx end=%lx flags=%x\n",
  217. bdata - bootmem_node_data,
  218. sidx + bdata->node_min_pfn,
  219. eidx + bdata->node_min_pfn,
  220. flags);
  221. for (idx = sidx; idx < eidx; idx++)
  222. if (test_and_set_bit(idx, bdata->node_bootmem_map)) {
  223. if (exclusive) {
  224. __free(bdata, sidx, idx);
  225. return -EBUSY;
  226. }
  227. bdebug("silent double reserve of PFN %lx\n",
  228. idx + bdata->node_min_pfn);
  229. }
  230. return 0;
  231. }
  232. static int __init mark_bootmem_node(bootmem_data_t *bdata,
  233. unsigned long start, unsigned long end,
  234. int reserve, int flags)
  235. {
  236. unsigned long sidx, eidx;
  237. bdebug("nid=%td start=%lx end=%lx reserve=%d flags=%x\n",
  238. bdata - bootmem_node_data, start, end, reserve, flags);
  239. BUG_ON(start < bdata->node_min_pfn);
  240. BUG_ON(end > bdata->node_low_pfn);
  241. sidx = start - bdata->node_min_pfn;
  242. eidx = end - bdata->node_min_pfn;
  243. if (reserve)
  244. return __reserve(bdata, sidx, eidx, flags);
  245. else
  246. __free(bdata, sidx, eidx);
  247. return 0;
  248. }
  249. static int __init mark_bootmem(unsigned long start, unsigned long end,
  250. int reserve, int flags)
  251. {
  252. unsigned long pos;
  253. bootmem_data_t *bdata;
  254. pos = start;
  255. list_for_each_entry(bdata, &bdata_list, list) {
  256. int err;
  257. unsigned long max;
  258. if (pos < bdata->node_min_pfn ||
  259. pos >= bdata->node_low_pfn) {
  260. BUG_ON(pos != start);
  261. continue;
  262. }
  263. max = min(bdata->node_low_pfn, end);
  264. err = mark_bootmem_node(bdata, pos, max, reserve, flags);
  265. if (reserve && err) {
  266. mark_bootmem(start, pos, 0, 0);
  267. return err;
  268. }
  269. if (max == end)
  270. return 0;
  271. pos = bdata->node_low_pfn;
  272. }
  273. BUG();
  274. }
  275. /**
  276. * free_bootmem_node - mark a page range as usable
  277. * @pgdat: node the range resides on
  278. * @physaddr: starting address of the range
  279. * @size: size of the range in bytes
  280. *
  281. * Partial pages will be considered reserved and left as they are.
  282. *
  283. * The range must reside completely on the specified node.
  284. */
  285. void __init free_bootmem_node(pg_data_t *pgdat, unsigned long physaddr,
  286. unsigned long size)
  287. {
  288. unsigned long start, end;
  289. start = PFN_UP(physaddr);
  290. end = PFN_DOWN(physaddr + size);
  291. mark_bootmem_node(pgdat->bdata, start, end, 0, 0);
  292. }
  293. /**
  294. * free_bootmem - mark a page range as usable
  295. * @addr: starting address of the range
  296. * @size: size of the range in bytes
  297. *
  298. * Partial pages will be considered reserved and left as they are.
  299. *
  300. * The range must be contiguous but may span node boundaries.
  301. */
  302. void __init free_bootmem(unsigned long addr, unsigned long size)
  303. {
  304. unsigned long start, end;
  305. start = PFN_UP(addr);
  306. end = PFN_DOWN(addr + size);
  307. mark_bootmem(start, end, 0, 0);
  308. }
  309. /**
  310. * reserve_bootmem_node - mark a page range as reserved
  311. * @pgdat: node the range resides on
  312. * @physaddr: starting address of the range
  313. * @size: size of the range in bytes
  314. * @flags: reservation flags (see linux/bootmem.h)
  315. *
  316. * Partial pages will be reserved.
  317. *
  318. * The range must reside completely on the specified node.
  319. */
  320. int __init reserve_bootmem_node(pg_data_t *pgdat, unsigned long physaddr,
  321. unsigned long size, int flags)
  322. {
  323. unsigned long start, end;
  324. start = PFN_DOWN(physaddr);
  325. end = PFN_UP(physaddr + size);
  326. return mark_bootmem_node(pgdat->bdata, start, end, 1, flags);
  327. }
  328. /**
  329. * reserve_bootmem - mark a page range as usable
  330. * @addr: starting address of the range
  331. * @size: size of the range in bytes
  332. * @flags: reservation flags (see linux/bootmem.h)
  333. *
  334. * Partial pages will be reserved.
  335. *
  336. * The range must be contiguous but may span node boundaries.
  337. */
  338. int __init reserve_bootmem(unsigned long addr, unsigned long size,
  339. int flags)
  340. {
  341. unsigned long start, end;
  342. start = PFN_DOWN(addr);
  343. end = PFN_UP(addr + size);
  344. return mark_bootmem(start, end, 1, flags);
  345. }
  346. static unsigned long align_idx(struct bootmem_data *bdata, unsigned long idx,
  347. unsigned long step)
  348. {
  349. unsigned long base = bdata->node_min_pfn;
  350. /*
  351. * Align the index with respect to the node start so that the
  352. * combination of both satisfies the requested alignment.
  353. */
  354. return ALIGN(base + idx, step) - base;
  355. }
  356. static unsigned long align_off(struct bootmem_data *bdata, unsigned long off,
  357. unsigned long align)
  358. {
  359. unsigned long base = PFN_PHYS(bdata->node_min_pfn);
  360. /* Same as align_idx for byte offsets */
  361. return ALIGN(base + off, align) - base;
  362. }
  363. static void * __init __alloc_bootmem_core(struct bootmem_data *bdata,
  364. unsigned long size, unsigned long align,
  365. unsigned long goal, unsigned long limit)
  366. {
  367. unsigned long fallback = 0;
  368. unsigned long min, max, start, sidx, midx, step;
  369. bdebug("nid=%td size=%lx [%lu pages] align=%lx goal=%lx limit=%lx\n",
  370. bdata - bootmem_node_data, size, PAGE_ALIGN(size) >> PAGE_SHIFT,
  371. align, goal, limit);
  372. BUG_ON(!size);
  373. BUG_ON(align & (align - 1));
  374. BUG_ON(limit && goal + size > limit);
  375. if (!bdata->node_bootmem_map)
  376. return NULL;
  377. min = bdata->node_min_pfn;
  378. max = bdata->node_low_pfn;
  379. goal >>= PAGE_SHIFT;
  380. limit >>= PAGE_SHIFT;
  381. if (limit && max > limit)
  382. max = limit;
  383. if (max <= min)
  384. return NULL;
  385. step = max(align >> PAGE_SHIFT, 1UL);
  386. if (goal && min < goal && goal < max)
  387. start = ALIGN(goal, step);
  388. else
  389. start = ALIGN(min, step);
  390. sidx = start - bdata->node_min_pfn;
  391. midx = max - bdata->node_min_pfn;
  392. if (bdata->hint_idx > sidx) {
  393. /*
  394. * Handle the valid case of sidx being zero and still
  395. * catch the fallback below.
  396. */
  397. fallback = sidx + 1;
  398. sidx = align_idx(bdata, bdata->hint_idx, step);
  399. }
  400. while (1) {
  401. int merge;
  402. void *region;
  403. unsigned long eidx, i, start_off, end_off;
  404. find_block:
  405. sidx = find_next_zero_bit(bdata->node_bootmem_map, midx, sidx);
  406. sidx = align_idx(bdata, sidx, step);
  407. eidx = sidx + PFN_UP(size);
  408. if (sidx >= midx || eidx > midx)
  409. break;
  410. for (i = sidx; i < eidx; i++)
  411. if (test_bit(i, bdata->node_bootmem_map)) {
  412. sidx = align_idx(bdata, i, step);
  413. if (sidx == i)
  414. sidx += step;
  415. goto find_block;
  416. }
  417. if (bdata->last_end_off & (PAGE_SIZE - 1) &&
  418. PFN_DOWN(bdata->last_end_off) + 1 == sidx)
  419. start_off = align_off(bdata, bdata->last_end_off, align);
  420. else
  421. start_off = PFN_PHYS(sidx);
  422. merge = PFN_DOWN(start_off) < sidx;
  423. end_off = start_off + size;
  424. bdata->last_end_off = end_off;
  425. bdata->hint_idx = PFN_UP(end_off);
  426. /*
  427. * Reserve the area now:
  428. */
  429. if (__reserve(bdata, PFN_DOWN(start_off) + merge,
  430. PFN_UP(end_off), BOOTMEM_EXCLUSIVE))
  431. BUG();
  432. region = phys_to_virt(PFN_PHYS(bdata->node_min_pfn) +
  433. start_off);
  434. memset(region, 0, size);
  435. return region;
  436. }
  437. if (fallback) {
  438. sidx = align_idx(bdata, fallback - 1, step);
  439. fallback = 0;
  440. goto find_block;
  441. }
  442. return NULL;
  443. }
  444. static void * __init ___alloc_bootmem_nopanic(unsigned long size,
  445. unsigned long align,
  446. unsigned long goal,
  447. unsigned long limit)
  448. {
  449. bootmem_data_t *bdata;
  450. restart:
  451. list_for_each_entry(bdata, &bdata_list, list) {
  452. void *region;
  453. if (goal && bdata->node_low_pfn <= PFN_DOWN(goal))
  454. continue;
  455. if (limit && bdata->node_min_pfn >= PFN_DOWN(limit))
  456. break;
  457. region = alloc_bootmem_core(bdata, size, align, goal, limit);
  458. if (region)
  459. return region;
  460. }
  461. if (goal) {
  462. goal = 0;
  463. goto restart;
  464. }
  465. return NULL;
  466. }
  467. /**
  468. * __alloc_bootmem_nopanic - allocate boot memory without panicking
  469. * @size: size of the request in bytes
  470. * @align: alignment of the region
  471. * @goal: preferred starting address of the region
  472. *
  473. * The goal is dropped if it can not be satisfied and the allocation will
  474. * fall back to memory below @goal.
  475. *
  476. * Allocation may happen on any node in the system.
  477. *
  478. * Returns NULL on failure.
  479. */
  480. void * __init __alloc_bootmem_nopanic(unsigned long size, unsigned long align,
  481. unsigned long goal)
  482. {
  483. return ___alloc_bootmem_nopanic(size, align, goal, 0);
  484. }
  485. static void * __init ___alloc_bootmem(unsigned long size, unsigned long align,
  486. unsigned long goal, unsigned long limit)
  487. {
  488. void *mem = ___alloc_bootmem_nopanic(size, align, goal, limit);
  489. if (mem)
  490. return mem;
  491. /*
  492. * Whoops, we cannot satisfy the allocation request.
  493. */
  494. printk(KERN_ALERT "bootmem alloc of %lu bytes failed!\n", size);
  495. panic("Out of memory");
  496. return NULL;
  497. }
  498. /**
  499. * __alloc_bootmem - allocate boot memory
  500. * @size: size of the request in bytes
  501. * @align: alignment of the region
  502. * @goal: preferred starting address of the region
  503. *
  504. * The goal is dropped if it can not be satisfied and the allocation will
  505. * fall back to memory below @goal.
  506. *
  507. * Allocation may happen on any node in the system.
  508. *
  509. * The function panics if the request can not be satisfied.
  510. */
  511. void * __init __alloc_bootmem(unsigned long size, unsigned long align,
  512. unsigned long goal)
  513. {
  514. return ___alloc_bootmem(size, align, goal, 0);
  515. }
  516. static void * __init ___alloc_bootmem_node(bootmem_data_t *bdata,
  517. unsigned long size, unsigned long align,
  518. unsigned long goal, unsigned long limit)
  519. {
  520. void *ptr;
  521. ptr = alloc_bootmem_core(bdata, size, align, goal, limit);
  522. if (ptr)
  523. return ptr;
  524. return ___alloc_bootmem(size, align, goal, limit);
  525. }
  526. /**
  527. * __alloc_bootmem_node - allocate boot memory from a specific node
  528. * @pgdat: node to allocate from
  529. * @size: size of the request in bytes
  530. * @align: alignment of the region
  531. * @goal: preferred starting address of the region
  532. *
  533. * The goal is dropped if it can not be satisfied and the allocation will
  534. * fall back to memory below @goal.
  535. *
  536. * Allocation may fall back to any node in the system if the specified node
  537. * can not hold the requested memory.
  538. *
  539. * The function panics if the request can not be satisfied.
  540. */
  541. void * __init __alloc_bootmem_node(pg_data_t *pgdat, unsigned long size,
  542. unsigned long align, unsigned long goal)
  543. {
  544. return ___alloc_bootmem_node(pgdat->bdata, size, align, goal, 0);
  545. }
  546. #ifdef CONFIG_SPARSEMEM
  547. /**
  548. * alloc_bootmem_section - allocate boot memory from a specific section
  549. * @size: size of the request in bytes
  550. * @section_nr: sparse map section to allocate from
  551. *
  552. * Return NULL on failure.
  553. */
  554. void * __init alloc_bootmem_section(unsigned long size,
  555. unsigned long section_nr)
  556. {
  557. bootmem_data_t *bdata;
  558. unsigned long pfn, goal, limit;
  559. pfn = section_nr_to_pfn(section_nr);
  560. goal = pfn << PAGE_SHIFT;
  561. limit = section_nr_to_pfn(section_nr + 1) << PAGE_SHIFT;
  562. bdata = &bootmem_node_data[early_pfn_to_nid(pfn)];
  563. return alloc_bootmem_core(bdata, size, SMP_CACHE_BYTES, goal, limit);
  564. }
  565. #endif
  566. void * __init __alloc_bootmem_node_nopanic(pg_data_t *pgdat, unsigned long size,
  567. unsigned long align, unsigned long goal)
  568. {
  569. void *ptr;
  570. ptr = alloc_bootmem_core(pgdat->bdata, size, align, goal, 0);
  571. if (ptr)
  572. return ptr;
  573. return __alloc_bootmem_nopanic(size, align, goal);
  574. }
  575. #ifndef ARCH_LOW_ADDRESS_LIMIT
  576. #define ARCH_LOW_ADDRESS_LIMIT 0xffffffffUL
  577. #endif
  578. /**
  579. * __alloc_bootmem_low - allocate low boot memory
  580. * @size: size of the request in bytes
  581. * @align: alignment of the region
  582. * @goal: preferred starting address of the region
  583. *
  584. * The goal is dropped if it can not be satisfied and the allocation will
  585. * fall back to memory below @goal.
  586. *
  587. * Allocation may happen on any node in the system.
  588. *
  589. * The function panics if the request can not be satisfied.
  590. */
  591. void * __init __alloc_bootmem_low(unsigned long size, unsigned long align,
  592. unsigned long goal)
  593. {
  594. return ___alloc_bootmem(size, align, goal, ARCH_LOW_ADDRESS_LIMIT);
  595. }
  596. /**
  597. * __alloc_bootmem_low_node - allocate low boot memory from a specific node
  598. * @pgdat: node to allocate from
  599. * @size: size of the request in bytes
  600. * @align: alignment of the region
  601. * @goal: preferred starting address of the region
  602. *
  603. * The goal is dropped if it can not be satisfied and the allocation will
  604. * fall back to memory below @goal.
  605. *
  606. * Allocation may fall back to any node in the system if the specified node
  607. * can not hold the requested memory.
  608. *
  609. * The function panics if the request can not be satisfied.
  610. */
  611. void * __init __alloc_bootmem_low_node(pg_data_t *pgdat, unsigned long size,
  612. unsigned long align, unsigned long goal)
  613. {
  614. return ___alloc_bootmem_node(pgdat->bdata, size, align,
  615. goal, ARCH_LOW_ADDRESS_LIMIT);
  616. }