aboutsummaryrefslogtreecommitdiffstats
path: root/mm/bootmem.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/bootmem.c')
-rw-r--r--mm/bootmem.c51
1 files changed, 44 insertions, 7 deletions
diff --git a/mm/bootmem.c b/mm/bootmem.c
index 105ad4cff2e..4e085ee1d98 100644
--- a/mm/bootmem.c
+++ b/mm/bootmem.c
@@ -34,6 +34,22 @@ unsigned long saved_max_pfn;
34 34
35bootmem_data_t bootmem_node_data[MAX_NUMNODES] __initdata; 35bootmem_data_t bootmem_node_data[MAX_NUMNODES] __initdata;
36 36
37static int bootmem_debug;
38
39static int __init bootmem_debug_setup(char *buf)
40{
41 bootmem_debug = 1;
42 return 0;
43}
44early_param("bootmem_debug", bootmem_debug_setup);
45
46#define bdebug(fmt, args...) ({ \
47 if (unlikely(bootmem_debug)) \
48 printk(KERN_INFO \
49 "bootmem::%s " fmt, \
50 __FUNCTION__, ## args); \
51})
52
37/* 53/*
38 * Given an initialised bdata, it returns the size of the boot bitmap 54 * Given an initialised bdata, it returns the size of the boot bitmap
39 */ 55 */
@@ -104,6 +120,9 @@ static unsigned long __init init_bootmem_core(bootmem_data_t *bdata,
104 mapsize = get_mapsize(bdata); 120 mapsize = get_mapsize(bdata);
105 memset(bdata->node_bootmem_map, 0xff, mapsize); 121 memset(bdata->node_bootmem_map, 0xff, mapsize);
106 122
123 bdebug("nid=%td start=%lx map=%lx end=%lx mapsize=%lx\n",
124 bdata - bootmem_node_data, start, mapstart, end, mapsize);
125
107 return mapsize; 126 return mapsize;
108} 127}
109 128
@@ -198,6 +217,8 @@ static unsigned long __init free_all_bootmem_core(bootmem_data_t *bdata)
198 count += i; 217 count += i;
199 bdata->node_bootmem_map = NULL; 218 bdata->node_bootmem_map = NULL;
200 219
220 bdebug("nid=%td released=%lx\n", bdata - bootmem_node_data, count);
221
201 return count; 222 return count;
202} 223}
203 224
@@ -255,6 +276,10 @@ static void __init free_bootmem_core(bootmem_data_t *bdata, unsigned long addr,
255 if (eidx > bdata->node_low_pfn - PFN_DOWN(bdata->node_boot_start)) 276 if (eidx > bdata->node_low_pfn - PFN_DOWN(bdata->node_boot_start))
256 eidx = bdata->node_low_pfn - PFN_DOWN(bdata->node_boot_start); 277 eidx = bdata->node_low_pfn - PFN_DOWN(bdata->node_boot_start);
257 278
279 bdebug("nid=%td start=%lx end=%lx\n", bdata - bootmem_node_data,
280 sidx + PFN_DOWN(bdata->node_boot_start),
281 eidx + PFN_DOWN(bdata->node_boot_start));
282
258 for (i = sidx; i < eidx; i++) { 283 for (i = sidx; i < eidx; i++) {
259 if (unlikely(!test_and_clear_bit(i, bdata->node_bootmem_map))) 284 if (unlikely(!test_and_clear_bit(i, bdata->node_bootmem_map)))
260 BUG(); 285 BUG();
@@ -360,13 +385,16 @@ static void __init reserve_bootmem_core(bootmem_data_t *bdata,
360 if (eidx > bdata->node_low_pfn - PFN_DOWN(bdata->node_boot_start)) 385 if (eidx > bdata->node_low_pfn - PFN_DOWN(bdata->node_boot_start))
361 eidx = bdata->node_low_pfn - PFN_DOWN(bdata->node_boot_start); 386 eidx = bdata->node_low_pfn - PFN_DOWN(bdata->node_boot_start);
362 387
363 for (i = sidx; i < eidx; i++) { 388 bdebug("nid=%td start=%lx end=%lx flags=%x\n",
364 if (test_and_set_bit(i, bdata->node_bootmem_map)) { 389 bdata - bootmem_node_data,
365#ifdef CONFIG_DEBUG_BOOTMEM 390 sidx + PFN_DOWN(bdata->node_boot_start),
366 printk("hm, page %08lx reserved twice.\n", i*PAGE_SIZE); 391 eidx + PFN_DOWN(bdata->node_boot_start),
367#endif 392 flags);
368 } 393
369 } 394 for (i = sidx; i < eidx; i++)
395 if (test_and_set_bit(i, bdata->node_bootmem_map))
396 bdebug("hm, page %lx reserved twice.\n",
397 PFN_DOWN(bdata->node_boot_start) + i);
370} 398}
371 399
372/** 400/**
@@ -455,6 +483,10 @@ alloc_bootmem_core(struct bootmem_data *bdata, unsigned long size,
455 if (!bdata->node_bootmem_map) 483 if (!bdata->node_bootmem_map)
456 return NULL; 484 return NULL;
457 485
486 bdebug("nid=%td size=%lx [%lu pages] align=%lx goal=%lx limit=%lx\n",
487 bdata - bootmem_node_data, size, PAGE_ALIGN(size) >> PAGE_SHIFT,
488 align, goal, limit);
489
458 /* bdata->node_boot_start is supposed to be (12+6)bits alignment on x86_64 ? */ 490 /* bdata->node_boot_start is supposed to be (12+6)bits alignment on x86_64 ? */
459 node_boot_start = bdata->node_boot_start; 491 node_boot_start = bdata->node_boot_start;
460 node_bootmem_map = bdata->node_bootmem_map; 492 node_bootmem_map = bdata->node_bootmem_map;
@@ -562,6 +594,11 @@ found:
562 ret = phys_to_virt(start * PAGE_SIZE + node_boot_start); 594 ret = phys_to_virt(start * PAGE_SIZE + node_boot_start);
563 } 595 }
564 596
597 bdebug("nid=%td start=%lx end=%lx\n",
598 bdata - bootmem_node_data,
599 start + PFN_DOWN(bdata->node_boot_start),
600 start + areasize + PFN_DOWN(bdata->node_boot_start));
601
565 /* 602 /*
566 * Reserve the area now: 603 * Reserve the area now:
567 */ 604 */