aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Weiner <hannes@saeurebad.de>2008-07-24 00:28:09 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-24 13:47:20 -0400
commit3560e249abda6bee41a07a7bf0383a6e193e2839 (patch)
treea5770b74f13dca64e34cd5a1e3182e4e1f98a9ca
parent75a56cfe9fdb064d1db1cfbc564315fddb756fb1 (diff)
bootmem: replace node_boot_start in struct bootmem_data
Almost all users of this field need a PFN instead of a physical address, so replace node_boot_start with node_min_pfn. [Lee.Schermerhorn@hp.com: fix spurious BUG_ON() in mark_bootmem()] Signed-off-by: Johannes Weiner <hannes@saeureba.de> Cc: <linux-arch@vger.kernel.org> Signed-off-by: Lee Schermerhorn <lee.schermerhorn@hp.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--arch/alpha/mm/numa.c2
-rw-r--r--arch/arm/plat-omap/fb.c4
-rw-r--r--arch/avr32/mm/init.c3
-rw-r--r--arch/ia64/mm/discontig.c19
-rw-r--r--arch/m32r/mm/discontig.c3
-rw-r--r--arch/m32r/mm/init.c4
-rw-r--r--arch/mn10300/mm/init.c6
-rw-r--r--arch/sh/mm/init.c2
-rw-r--r--include/linux/bootmem.h2
-rw-r--r--mm/bootmem.c40
10 files changed, 41 insertions, 44 deletions
diff --git a/arch/alpha/mm/numa.c b/arch/alpha/mm/numa.c
index def0c74a78a8..d8c4ceaf00b9 100644
--- a/arch/alpha/mm/numa.c
+++ b/arch/alpha/mm/numa.c
@@ -304,7 +304,7 @@ void __init paging_init(void)
304 304
305 for_each_online_node(nid) { 305 for_each_online_node(nid) {
306 bootmem_data_t *bdata = &bootmem_node_data[nid]; 306 bootmem_data_t *bdata = &bootmem_node_data[nid];
307 unsigned long start_pfn = bdata->node_boot_start >> PAGE_SHIFT; 307 unsigned long start_pfn = bdata->node_min_pfn;
308 unsigned long end_pfn = bdata->node_low_pfn; 308 unsigned long end_pfn = bdata->node_low_pfn;
309 309
310 if (dma_local_pfn >= end_pfn - start_pfn) 310 if (dma_local_pfn >= end_pfn - start_pfn)
diff --git a/arch/arm/plat-omap/fb.c b/arch/arm/plat-omap/fb.c
index 7854f19b77cf..96d6f0619733 100644
--- a/arch/arm/plat-omap/fb.c
+++ b/arch/arm/plat-omap/fb.c
@@ -182,7 +182,7 @@ void __init omapfb_reserve_sdram(void)
182 return; 182 return;
183 183
184 bdata = NODE_DATA(0)->bdata; 184 bdata = NODE_DATA(0)->bdata;
185 sdram_start = bdata->node_boot_start; 185 sdram_start = bdata->node_min_pfn << PAGE_SHIFT;
186 sdram_size = (bdata->node_low_pfn << PAGE_SHIFT) - sdram_start; 186 sdram_size = (bdata->node_low_pfn << PAGE_SHIFT) - sdram_start;
187 reserved = 0; 187 reserved = 0;
188 for (i = 0; ; i++) { 188 for (i = 0; ; i++) {
@@ -340,5 +340,3 @@ unsigned long omapfb_reserve_sram(unsigned long sram_pstart,
340 340
341 341
342#endif 342#endif
343
344
diff --git a/arch/avr32/mm/init.c b/arch/avr32/mm/init.c
index 786de88a82a7..3c85fdaa9487 100644
--- a/arch/avr32/mm/init.c
+++ b/arch/avr32/mm/init.c
@@ -119,8 +119,7 @@ void __init paging_init(void)
119 unsigned long zones_size[MAX_NR_ZONES]; 119 unsigned long zones_size[MAX_NR_ZONES];
120 unsigned long low, start_pfn; 120 unsigned long low, start_pfn;
121 121
122 start_pfn = pgdat->bdata->node_boot_start; 122 start_pfn = pgdat->bdata->node_min_pfn;
123 start_pfn >>= PAGE_SHIFT;
124 low = pgdat->bdata->node_low_pfn; 123 low = pgdat->bdata->node_low_pfn;
125 124
126 memset(zones_size, 0, sizeof(zones_size)); 125 memset(zones_size, 0, sizeof(zones_size));
diff --git a/arch/ia64/mm/discontig.c b/arch/ia64/mm/discontig.c
index 2fcf8464331e..d83125e1ed27 100644
--- a/arch/ia64/mm/discontig.c
+++ b/arch/ia64/mm/discontig.c
@@ -74,17 +74,17 @@ pg_data_t *pgdat_list[MAX_NUMNODES];
74static int __init build_node_maps(unsigned long start, unsigned long len, 74static int __init build_node_maps(unsigned long start, unsigned long len,
75 int node) 75 int node)
76{ 76{
77 unsigned long cstart, epfn, end = start + len; 77 unsigned long spfn, epfn, end = start + len;
78 struct bootmem_data *bdp = &bootmem_node_data[node]; 78 struct bootmem_data *bdp = &bootmem_node_data[node];
79 79
80 epfn = GRANULEROUNDUP(end) >> PAGE_SHIFT; 80 epfn = GRANULEROUNDUP(end) >> PAGE_SHIFT;
81 cstart = GRANULEROUNDDOWN(start); 81 spfn = GRANULEROUNDDOWN(start) >> PAGE_SHIFT;
82 82
83 if (!bdp->node_low_pfn) { 83 if (!bdp->node_low_pfn) {
84 bdp->node_boot_start = cstart; 84 bdp->node_min_pfn = spfn;
85 bdp->node_low_pfn = epfn; 85 bdp->node_low_pfn = epfn;
86 } else { 86 } else {
87 bdp->node_boot_start = min(cstart, bdp->node_boot_start); 87 bdp->node_min_pfn = min(spfn, bdp->node_min_pfn);
88 bdp->node_low_pfn = max(epfn, bdp->node_low_pfn); 88 bdp->node_low_pfn = max(epfn, bdp->node_low_pfn);
89 } 89 }
90 90
@@ -221,20 +221,21 @@ static void __init fill_pernode(int node, unsigned long pernode,
221static int __init find_pernode_space(unsigned long start, unsigned long len, 221static int __init find_pernode_space(unsigned long start, unsigned long len,
222 int node) 222 int node)
223{ 223{
224 unsigned long epfn; 224 unsigned long spfn, epfn;
225 unsigned long pernodesize = 0, pernode, pages, mapsize; 225 unsigned long pernodesize = 0, pernode, pages, mapsize;
226 struct bootmem_data *bdp = &bootmem_node_data[node]; 226 struct bootmem_data *bdp = &bootmem_node_data[node];
227 227
228 spfn = start >> PAGE_SHIFT;
228 epfn = (start + len) >> PAGE_SHIFT; 229 epfn = (start + len) >> PAGE_SHIFT;
229 230
230 pages = bdp->node_low_pfn - (bdp->node_boot_start >> PAGE_SHIFT); 231 pages = bdp->node_low_pfn - bdp->node_min_pfn;
231 mapsize = bootmem_bootmap_pages(pages) << PAGE_SHIFT; 232 mapsize = bootmem_bootmap_pages(pages) << PAGE_SHIFT;
232 233
233 /* 234 /*
234 * Make sure this memory falls within this node's usable memory 235 * Make sure this memory falls within this node's usable memory
235 * since we may have thrown some away in build_maps(). 236 * since we may have thrown some away in build_maps().
236 */ 237 */
237 if (start < bdp->node_boot_start || epfn > bdp->node_low_pfn) 238 if (spfn < bdp->node_min_pfn || epfn > bdp->node_low_pfn)
238 return 0; 239 return 0;
239 240
240 /* Don't setup this node's local space twice... */ 241 /* Don't setup this node's local space twice... */
@@ -296,7 +297,7 @@ static void __init reserve_pernode_space(void)
296 bdp = pdp->bdata; 297 bdp = pdp->bdata;
297 298
298 /* First the bootmem_map itself */ 299 /* First the bootmem_map itself */
299 pages = bdp->node_low_pfn - (bdp->node_boot_start>>PAGE_SHIFT); 300 pages = bdp->node_low_pfn - bdp->node_min_pfn;
300 size = bootmem_bootmap_pages(pages) << PAGE_SHIFT; 301 size = bootmem_bootmap_pages(pages) << PAGE_SHIFT;
301 base = __pa(bdp->node_bootmem_map); 302 base = __pa(bdp->node_bootmem_map);
302 reserve_bootmem_node(pdp, base, size, BOOTMEM_DEFAULT); 303 reserve_bootmem_node(pdp, base, size, BOOTMEM_DEFAULT);
@@ -466,7 +467,7 @@ void __init find_memory(void)
466 467
467 init_bootmem_node(pgdat_list[node], 468 init_bootmem_node(pgdat_list[node],
468 map>>PAGE_SHIFT, 469 map>>PAGE_SHIFT,
469 bdp->node_boot_start>>PAGE_SHIFT, 470 bdp->node_min_pfn,
470 bdp->node_low_pfn); 471 bdp->node_low_pfn);
471 } 472 }
472 473
diff --git a/arch/m32r/mm/discontig.c b/arch/m32r/mm/discontig.c
index cc23934bc41e..cbc3c4c54566 100644
--- a/arch/m32r/mm/discontig.c
+++ b/arch/m32r/mm/discontig.c
@@ -123,8 +123,7 @@ unsigned long __init setup_memory(void)
123 return max_low_pfn; 123 return max_low_pfn;
124} 124}
125 125
126#define START_PFN(nid) \ 126#define START_PFN(nid) (NODE_DATA(nid)->bdata->node_min_pfn)
127 (NODE_DATA(nid)->bdata->node_boot_start >> PAGE_SHIFT)
128#define MAX_LOW_PFN(nid) (NODE_DATA(nid)->bdata->node_low_pfn) 127#define MAX_LOW_PFN(nid) (NODE_DATA(nid)->bdata->node_low_pfn)
129 128
130unsigned long __init zone_sizes_init(void) 129unsigned long __init zone_sizes_init(void)
diff --git a/arch/m32r/mm/init.c b/arch/m32r/mm/init.c
index 28799af15e95..2554eb59cfef 100644
--- a/arch/m32r/mm/init.c
+++ b/arch/m32r/mm/init.c
@@ -93,8 +93,7 @@ void free_initrd_mem(unsigned long, unsigned long);
93#endif 93#endif
94 94
95/* It'd be good if these lines were in the standard header file. */ 95/* It'd be good if these lines were in the standard header file. */
96#define START_PFN(nid) \ 96#define START_PFN(nid) (NODE_DATA(nid)->bdata->node_min_pfn)
97 (NODE_DATA(nid)->bdata->node_boot_start >> PAGE_SHIFT)
98#define MAX_LOW_PFN(nid) (NODE_DATA(nid)->bdata->node_low_pfn) 97#define MAX_LOW_PFN(nid) (NODE_DATA(nid)->bdata->node_low_pfn)
99 98
100#ifndef CONFIG_DISCONTIGMEM 99#ifndef CONFIG_DISCONTIGMEM
@@ -252,4 +251,3 @@ void free_initrd_mem(unsigned long start, unsigned long end)
252 printk (KERN_INFO "Freeing initrd memory: %ldk freed\n", (end - start) >> 10); 251 printk (KERN_INFO "Freeing initrd memory: %ldk freed\n", (end - start) >> 10);
253} 252}
254#endif 253#endif
255
diff --git a/arch/mn10300/mm/init.c b/arch/mn10300/mm/init.c
index 8c5d88c7b90a..8cee387a24fd 100644
--- a/arch/mn10300/mm/init.c
+++ b/arch/mn10300/mm/init.c
@@ -67,8 +67,8 @@ void __init paging_init(void)
67 67
68 /* declare the sizes of the RAM zones (only use the normal zone) */ 68 /* declare the sizes of the RAM zones (only use the normal zone) */
69 zones_size[ZONE_NORMAL] = 69 zones_size[ZONE_NORMAL] =
70 (contig_page_data.bdata->node_low_pfn) - 70 contig_page_data.bdata->node_low_pfn -
71 (contig_page_data.bdata->node_boot_start >> PAGE_SHIFT); 71 contig_page_data.bdata->node_min_pfn;
72 72
73 /* pass the memory from the bootmem allocator to the main allocator */ 73 /* pass the memory from the bootmem allocator to the main allocator */
74 free_area_init(zones_size); 74 free_area_init(zones_size);
@@ -87,7 +87,7 @@ void __init mem_init(void)
87 if (!mem_map) 87 if (!mem_map)
88 BUG(); 88 BUG();
89 89
90#define START_PFN (contig_page_data.bdata->node_boot_start >> PAGE_SHIFT) 90#define START_PFN (contig_page_data.bdata->node_min_pfn)
91#define MAX_LOW_PFN (contig_page_data.bdata->node_low_pfn) 91#define MAX_LOW_PFN (contig_page_data.bdata->node_low_pfn)
92 92
93 max_mapnr = num_physpages = MAX_LOW_PFN - START_PFN; 93 max_mapnr = num_physpages = MAX_LOW_PFN - START_PFN;
diff --git a/arch/sh/mm/init.c b/arch/sh/mm/init.c
index d7df26bd1e54..d652d375eb1e 100644
--- a/arch/sh/mm/init.c
+++ b/arch/sh/mm/init.c
@@ -191,7 +191,7 @@ void __init paging_init(void)
191 pg_data_t *pgdat = NODE_DATA(nid); 191 pg_data_t *pgdat = NODE_DATA(nid);
192 unsigned long low, start_pfn; 192 unsigned long low, start_pfn;
193 193
194 start_pfn = pgdat->bdata->node_boot_start >> PAGE_SHIFT; 194 start_pfn = pgdat->bdata->node_min_pfn;
195 low = pgdat->bdata->node_low_pfn; 195 low = pgdat->bdata->node_low_pfn;
196 196
197 if (max_zone_pfns[ZONE_NORMAL] < low) 197 if (max_zone_pfns[ZONE_NORMAL] < low)
diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h
index 90921d10ffa2..4ddf2922fc8d 100644
--- a/include/linux/bootmem.h
+++ b/include/linux/bootmem.h
@@ -28,7 +28,7 @@ extern unsigned long saved_max_pfn;
28 * memory pages (including holes) on the node. 28 * memory pages (including holes) on the node.
29 */ 29 */
30typedef struct bootmem_data { 30typedef struct bootmem_data {
31 unsigned long node_boot_start; 31 unsigned long node_min_pfn;
32 unsigned long node_low_pfn; 32 unsigned long node_low_pfn;
33 void *node_bootmem_map; 33 void *node_bootmem_map;
34 unsigned long last_end_off; 34 unsigned long last_end_off;
diff --git a/mm/bootmem.c b/mm/bootmem.c
index 282b786c2b15..4af15d0340ad 100644
--- a/mm/bootmem.c
+++ b/mm/bootmem.c
@@ -80,7 +80,7 @@ static void __init link_bootmem(bootmem_data_t *bdata)
80 bootmem_data_t *ent; 80 bootmem_data_t *ent;
81 81
82 ent = list_entry(iter, bootmem_data_t, list); 82 ent = list_entry(iter, bootmem_data_t, list);
83 if (bdata->node_boot_start < ent->node_boot_start) 83 if (bdata->node_min_pfn < ent->node_min_pfn)
84 break; 84 break;
85 } 85 }
86 list_add_tail(&bdata->list, iter); 86 list_add_tail(&bdata->list, iter);
@@ -96,7 +96,7 @@ static unsigned long __init init_bootmem_core(bootmem_data_t *bdata,
96 96
97 mminit_validate_memmodel_limits(&start, &end); 97 mminit_validate_memmodel_limits(&start, &end);
98 bdata->node_bootmem_map = phys_to_virt(PFN_PHYS(mapstart)); 98 bdata->node_bootmem_map = phys_to_virt(PFN_PHYS(mapstart));
99 bdata->node_boot_start = PFN_PHYS(start); 99 bdata->node_min_pfn = start;
100 bdata->node_low_pfn = end; 100 bdata->node_low_pfn = end;
101 link_bootmem(bdata); 101 link_bootmem(bdata);
102 102
@@ -151,7 +151,7 @@ static unsigned long __init free_all_bootmem_core(bootmem_data_t *bdata)
151 if (!bdata->node_bootmem_map) 151 if (!bdata->node_bootmem_map)
152 return 0; 152 return 0;
153 153
154 start = PFN_DOWN(bdata->node_boot_start); 154 start = bdata->node_min_pfn;
155 end = bdata->node_low_pfn; 155 end = bdata->node_low_pfn;
156 156
157 /* 157 /*
@@ -167,7 +167,7 @@ static unsigned long __init free_all_bootmem_core(bootmem_data_t *bdata)
167 unsigned long *map, idx, vec; 167 unsigned long *map, idx, vec;
168 168
169 map = bdata->node_bootmem_map; 169 map = bdata->node_bootmem_map;
170 idx = start - PFN_DOWN(bdata->node_boot_start); 170 idx = start - bdata->node_min_pfn;
171 vec = ~map[idx / BITS_PER_LONG]; 171 vec = ~map[idx / BITS_PER_LONG];
172 172
173 if (aligned && vec == ~0UL && start + BITS_PER_LONG < end) { 173 if (aligned && vec == ~0UL && start + BITS_PER_LONG < end) {
@@ -192,7 +192,7 @@ static unsigned long __init free_all_bootmem_core(bootmem_data_t *bdata)
192 } 192 }
193 193
194 page = virt_to_page(bdata->node_bootmem_map); 194 page = virt_to_page(bdata->node_bootmem_map);
195 pages = bdata->node_low_pfn - PFN_DOWN(bdata->node_boot_start); 195 pages = bdata->node_low_pfn - bdata->node_min_pfn;
196 pages = bootmem_bootmap_pages(pages); 196 pages = bootmem_bootmap_pages(pages);
197 count += pages; 197 count += pages;
198 while (pages--) 198 while (pages--)
@@ -231,8 +231,8 @@ static void __init __free(bootmem_data_t *bdata,
231 unsigned long idx; 231 unsigned long idx;
232 232
233 bdebug("nid=%td start=%lx end=%lx\n", bdata - bootmem_node_data, 233 bdebug("nid=%td start=%lx end=%lx\n", bdata - bootmem_node_data,
234 sidx + PFN_DOWN(bdata->node_boot_start), 234 sidx + bdata->node_min_pfn,
235 eidx + PFN_DOWN(bdata->node_boot_start)); 235 eidx + bdata->node_min_pfn);
236 236
237 if (bdata->hint_idx > sidx) 237 if (bdata->hint_idx > sidx)
238 bdata->hint_idx = sidx; 238 bdata->hint_idx = sidx;
@@ -250,8 +250,8 @@ static int __init __reserve(bootmem_data_t *bdata, unsigned long sidx,
250 250
251 bdebug("nid=%td start=%lx end=%lx flags=%x\n", 251 bdebug("nid=%td start=%lx end=%lx flags=%x\n",
252 bdata - bootmem_node_data, 252 bdata - bootmem_node_data,
253 sidx + PFN_DOWN(bdata->node_boot_start), 253 sidx + bdata->node_min_pfn,
254 eidx + PFN_DOWN(bdata->node_boot_start), 254 eidx + bdata->node_min_pfn,
255 flags); 255 flags);
256 256
257 for (idx = sidx; idx < eidx; idx++) 257 for (idx = sidx; idx < eidx; idx++)
@@ -261,7 +261,7 @@ static int __init __reserve(bootmem_data_t *bdata, unsigned long sidx,
261 return -EBUSY; 261 return -EBUSY;
262 } 262 }
263 bdebug("silent double reserve of PFN %lx\n", 263 bdebug("silent double reserve of PFN %lx\n",
264 idx + PFN_DOWN(bdata->node_boot_start)); 264 idx + bdata->node_min_pfn);
265 } 265 }
266 return 0; 266 return 0;
267} 267}
@@ -275,11 +275,11 @@ static int __init mark_bootmem_node(bootmem_data_t *bdata,
275 bdebug("nid=%td start=%lx end=%lx reserve=%d flags=%x\n", 275 bdebug("nid=%td start=%lx end=%lx reserve=%d flags=%x\n",
276 bdata - bootmem_node_data, start, end, reserve, flags); 276 bdata - bootmem_node_data, start, end, reserve, flags);
277 277
278 BUG_ON(start < PFN_DOWN(bdata->node_boot_start)); 278 BUG_ON(start < bdata->node_min_pfn);
279 BUG_ON(end > bdata->node_low_pfn); 279 BUG_ON(end > bdata->node_low_pfn);
280 280
281 sidx = start - PFN_DOWN(bdata->node_boot_start); 281 sidx = start - bdata->node_min_pfn;
282 eidx = end - PFN_DOWN(bdata->node_boot_start); 282 eidx = end - bdata->node_min_pfn;
283 283
284 if (reserve) 284 if (reserve)
285 return __reserve(bdata, sidx, eidx, flags); 285 return __reserve(bdata, sidx, eidx, flags);
@@ -299,7 +299,8 @@ static int __init mark_bootmem(unsigned long start, unsigned long end,
299 int err; 299 int err;
300 unsigned long max; 300 unsigned long max;
301 301
302 if (pos < PFN_DOWN(bdata->node_boot_start)) { 302 if (pos < bdata->node_min_pfn ||
303 pos >= bdata->node_low_pfn) {
303 BUG_ON(pos != start); 304 BUG_ON(pos != start);
304 continue; 305 continue;
305 } 306 }
@@ -422,7 +423,7 @@ static void * __init alloc_bootmem_core(struct bootmem_data *bdata,
422 bdata - bootmem_node_data, size, PAGE_ALIGN(size) >> PAGE_SHIFT, 423 bdata - bootmem_node_data, size, PAGE_ALIGN(size) >> PAGE_SHIFT,
423 align, goal, limit); 424 align, goal, limit);
424 425
425 min = PFN_DOWN(bdata->node_boot_start); 426 min = bdata->node_min_pfn;
426 max = bdata->node_low_pfn; 427 max = bdata->node_low_pfn;
427 428
428 goal >>= PAGE_SHIFT; 429 goal >>= PAGE_SHIFT;
@@ -440,8 +441,8 @@ static void * __init alloc_bootmem_core(struct bootmem_data *bdata,
440 else 441 else
441 start = ALIGN(min, step); 442 start = ALIGN(min, step);
442 443
443 sidx = start - PFN_DOWN(bdata->node_boot_start); 444 sidx = start - bdata->node_min_pfn;;
444 midx = max - PFN_DOWN(bdata->node_boot_start); 445 midx = max - bdata->node_min_pfn;
445 446
446 if (bdata->hint_idx > sidx) { 447 if (bdata->hint_idx > sidx) {
447 /* 448 /*
@@ -491,7 +492,8 @@ find_block:
491 PFN_UP(end_off), BOOTMEM_EXCLUSIVE)) 492 PFN_UP(end_off), BOOTMEM_EXCLUSIVE))
492 BUG(); 493 BUG();
493 494
494 region = phys_to_virt(bdata->node_boot_start + start_off); 495 region = phys_to_virt(PFN_PHYS(bdata->node_min_pfn) +
496 start_off);
495 memset(region, 0, size); 497 memset(region, 0, size);
496 return region; 498 return region;
497 } 499 }
@@ -518,7 +520,7 @@ restart:
518 520
519 if (goal && bdata->node_low_pfn <= PFN_DOWN(goal)) 521 if (goal && bdata->node_low_pfn <= PFN_DOWN(goal))
520 continue; 522 continue;
521 if (limit && bdata->node_boot_start >= limit) 523 if (limit && bdata->node_min_pfn >= PFN_DOWN(limit))
522 break; 524 break;
523 525
524 region = alloc_bootmem_core(bdata, size, align, goal, limit); 526 region = alloc_bootmem_core(bdata, size, align, goal, limit);