Commit df049a5f authored by Johannes Weiner's avatar Johannes Weiner Committed by Linus Torvalds

bootmem: revisit bitmap size calculations

Reincarnate get_mapsize as bootmap_bytes and implement
bootmem_bootmap_pages on top of it.

Adjust users of these helpers and make free_all_bootmem_core use
bootmem_bootmap_pages instead of open-coding it.
Signed-off-by: default avatarJohannes Weiner <hannes@saeurebad.de>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 2e5237da
...@@ -50,17 +50,11 @@ early_param("bootmem_debug", bootmem_debug_setup); ...@@ -50,17 +50,11 @@ early_param("bootmem_debug", bootmem_debug_setup);
__FUNCTION__, ## args); \ __FUNCTION__, ## args); \
}) })
/* static unsigned long __init bootmap_bytes(unsigned long pages)
* Given an initialised bdata, it returns the size of the boot bitmap
*/
static unsigned long __init get_mapsize(bootmem_data_t *bdata)
{ {
unsigned long mapsize; unsigned long bytes = (pages + 7) / 8;
unsigned long start = PFN_DOWN(bdata->node_boot_start);
unsigned long end = bdata->node_low_pfn;
mapsize = ((end - start) + 7) / 8; return ALIGN(bytes, sizeof(long));
return ALIGN(mapsize, sizeof(long));
} }
/** /**
...@@ -69,13 +63,9 @@ static unsigned long __init get_mapsize(bootmem_data_t *bdata) ...@@ -69,13 +63,9 @@ static unsigned long __init get_mapsize(bootmem_data_t *bdata)
*/ */
unsigned long __init bootmem_bootmap_pages(unsigned long pages) unsigned long __init bootmem_bootmap_pages(unsigned long pages)
{ {
unsigned long mapsize; unsigned long bytes = bootmap_bytes(pages);
mapsize = (pages+7)/8;
mapsize = (mapsize + ~PAGE_MASK) & PAGE_MASK;
mapsize >>= PAGE_SHIFT;
return mapsize; return PAGE_ALIGN(bytes) >> PAGE_SHIFT;
} }
/* /*
...@@ -117,7 +107,7 @@ static unsigned long __init init_bootmem_core(bootmem_data_t *bdata, ...@@ -117,7 +107,7 @@ static unsigned long __init init_bootmem_core(bootmem_data_t *bdata,
* Initially all pages are reserved - setup_arch() has to * Initially all pages are reserved - setup_arch() has to
* register free RAM areas explicitly. * register free RAM areas explicitly.
*/ */
mapsize = get_mapsize(bdata); mapsize = bootmap_bytes(end - start);
memset(bdata->node_bootmem_map, 0xff, mapsize); memset(bdata->node_bootmem_map, 0xff, mapsize);
bdebug("nid=%td start=%lx map=%lx end=%lx mapsize=%lx\n", bdebug("nid=%td start=%lx map=%lx end=%lx mapsize=%lx\n",
...@@ -160,7 +150,7 @@ static unsigned long __init free_all_bootmem_core(bootmem_data_t *bdata) ...@@ -160,7 +150,7 @@ static unsigned long __init free_all_bootmem_core(bootmem_data_t *bdata)
struct page *page; struct page *page;
unsigned long pfn; unsigned long pfn;
unsigned long i, count; unsigned long i, count;
unsigned long idx; unsigned long idx, pages;
unsigned long *map; unsigned long *map;
int gofast = 0; int gofast = 0;
...@@ -211,7 +201,8 @@ static unsigned long __init free_all_bootmem_core(bootmem_data_t *bdata) ...@@ -211,7 +201,8 @@ static unsigned long __init free_all_bootmem_core(bootmem_data_t *bdata)
* needed anymore: * needed anymore:
*/ */
page = virt_to_page(bdata->node_bootmem_map); page = virt_to_page(bdata->node_bootmem_map);
idx = (get_mapsize(bdata) + PAGE_SIZE-1) >> PAGE_SHIFT; pages = bdata->node_low_pfn - PFN_DOWN(bdata->node_boot_start);
idx = bootmem_bootmap_pages(pages);
for (i = 0; i < idx; i++, page++) for (i = 0; i < idx; i++, page++)
__free_pages_bootmem(page, 0); __free_pages_bootmem(page, 0);
count += i; count += i;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment