aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Weiner <hannes@saeurebad.de>2008-07-24 00:28:02 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-24 13:47:20 -0400
commitdf049a5f41a3b2eee2131221959e3b558ba7c705 (patch)
treedcba7fb3e442838e93e2fb0deb66acc79372b123
parent2e5237daf0cc3c8d87762f53f704dc54fa91dcf6 (diff)
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: Johannes Weiner <hannes@saeurebad.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--mm/bootmem.c27
1 files changed, 9 insertions, 18 deletions
diff --git a/mm/bootmem.c b/mm/bootmem.c
index 4e085ee1d98e..484849bfc8c4 100644
--- a/mm/bootmem.c
+++ b/mm/bootmem.c
@@ -50,17 +50,11 @@ early_param("bootmem_debug", bootmem_debug_setup);
50 __FUNCTION__, ## args); \ 50 __FUNCTION__, ## args); \
51}) 51})
52 52
53/* 53static unsigned long __init bootmap_bytes(unsigned long pages)
54 * Given an initialised bdata, it returns the size of the boot bitmap
55 */
56static unsigned long __init get_mapsize(bootmem_data_t *bdata)
57{ 54{
58 unsigned long mapsize; 55 unsigned long bytes = (pages + 7) / 8;
59 unsigned long start = PFN_DOWN(bdata->node_boot_start);
60 unsigned long end = bdata->node_low_pfn;
61 56
62 mapsize = ((end - start) + 7) / 8; 57 return ALIGN(bytes, sizeof(long));
63 return ALIGN(mapsize, sizeof(long));
64} 58}
65 59
66/** 60/**
@@ -69,13 +63,9 @@ static unsigned long __init get_mapsize(bootmem_data_t *bdata)
69 */ 63 */
70unsigned long __init bootmem_bootmap_pages(unsigned long pages) 64unsigned long __init bootmem_bootmap_pages(unsigned long pages)
71{ 65{
72 unsigned long mapsize; 66 unsigned long bytes = bootmap_bytes(pages);
73
74 mapsize = (pages+7)/8;
75 mapsize = (mapsize + ~PAGE_MASK) & PAGE_MASK;
76 mapsize >>= PAGE_SHIFT;
77 67
78 return mapsize; 68 return PAGE_ALIGN(bytes) >> PAGE_SHIFT;
79} 69}
80 70
81/* 71/*
@@ -117,7 +107,7 @@ static unsigned long __init init_bootmem_core(bootmem_data_t *bdata,
117 * Initially all pages are reserved - setup_arch() has to 107 * Initially all pages are reserved - setup_arch() has to
118 * register free RAM areas explicitly. 108 * register free RAM areas explicitly.
119 */ 109 */
120 mapsize = get_mapsize(bdata); 110 mapsize = bootmap_bytes(end - start);
121 memset(bdata->node_bootmem_map, 0xff, mapsize); 111 memset(bdata->node_bootmem_map, 0xff, mapsize);
122 112
123 bdebug("nid=%td start=%lx map=%lx end=%lx mapsize=%lx\n", 113 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 struct page *page; 150 struct page *page;
161 unsigned long pfn; 151 unsigned long pfn;
162 unsigned long i, count; 152 unsigned long i, count;
163 unsigned long idx; 153 unsigned long idx, pages;
164 unsigned long *map; 154 unsigned long *map;
165 int gofast = 0; 155 int gofast = 0;
166 156
@@ -211,7 +201,8 @@ static unsigned long __init free_all_bootmem_core(bootmem_data_t *bdata)
211 * needed anymore: 201 * needed anymore:
212 */ 202 */
213 page = virt_to_page(bdata->node_bootmem_map); 203 page = virt_to_page(bdata->node_bootmem_map);
214 idx = (get_mapsize(bdata) + PAGE_SIZE-1) >> PAGE_SHIFT; 204 pages = bdata->node_low_pfn - PFN_DOWN(bdata->node_boot_start);
205 idx = bootmem_bootmap_pages(pages);
215 for (i = 0; i < idx; i++, page++) 206 for (i = 0; i < idx; i++, page++)
216 __free_pages_bootmem(page, 0); 207 __free_pages_bootmem(page, 0);
217 count += i; 208 count += i;