Commit 2e5237daf0cc3c8d87762f53f704dc54fa91dcf6

Authored by Johannes Weiner
Committed by Linus Torvalds
1 parent a66fd7daec

bootmem: add debugging framework

Introduce the bootmem_debug kernel parameter that enables very verbose
diagnostics regarding all range operations of bootmem as well as the
initialization and release of nodes.

[akpm@linux-foundation.org: fix printk warnings]
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>

Showing 1 changed file with 44 additions and 7 deletions Side-by-side Diff

... ... @@ -34,6 +34,22 @@
34 34  
35 35 bootmem_data_t bootmem_node_data[MAX_NUMNODES] __initdata;
36 36  
  37 +static int bootmem_debug;
  38 +
  39 +static int __init bootmem_debug_setup(char *buf)
  40 +{
  41 + bootmem_debug = 1;
  42 + return 0;
  43 +}
  44 +early_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 54 * Given an initialised bdata, it returns the size of the boot bitmap
39 55 */
... ... @@ -104,6 +120,9 @@
104 120 mapsize = get_mapsize(bdata);
105 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 126 return mapsize;
108 127 }
109 128  
... ... @@ -198,6 +217,8 @@
198 217 count += i;
199 218 bdata->node_bootmem_map = NULL;
200 219  
  220 + bdebug("nid=%td released=%lx\n", bdata - bootmem_node_data, count);
  221 +
201 222 return count;
202 223 }
203 224  
... ... @@ -255,6 +276,10 @@
255 276 if (eidx > bdata->node_low_pfn - PFN_DOWN(bdata->node_boot_start))
256 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 283 for (i = sidx; i < eidx; i++) {
259 284 if (unlikely(!test_and_clear_bit(i, bdata->node_bootmem_map)))
260 285 BUG();
... ... @@ -360,13 +385,16 @@
360 385 if (eidx > bdata->node_low_pfn - PFN_DOWN(bdata->node_boot_start))
361 386 eidx = bdata->node_low_pfn - PFN_DOWN(bdata->node_boot_start);
362 387  
363   - for (i = sidx; i < eidx; i++) {
364   - if (test_and_set_bit(i, bdata->node_bootmem_map)) {
365   -#ifdef CONFIG_DEBUG_BOOTMEM
366   - printk("hm, page %08lx reserved twice.\n", i*PAGE_SIZE);
367   -#endif
368   - }
369   - }
  388 + bdebug("nid=%td start=%lx end=%lx flags=%x\n",
  389 + bdata - bootmem_node_data,
  390 + sidx + PFN_DOWN(bdata->node_boot_start),
  391 + eidx + PFN_DOWN(bdata->node_boot_start),
  392 + flags);
  393 +
  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 @@
455 483 if (!bdata->node_bootmem_map)
456 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 490 /* bdata->node_boot_start is supposed to be (12+6)bits alignment on x86_64 ? */
459 491 node_boot_start = bdata->node_boot_start;
460 492 node_bootmem_map = bdata->node_bootmem_map;
... ... @@ -561,6 +593,11 @@
561 593 bdata->last_offset = size & ~PAGE_MASK;
562 594 ret = phys_to_virt(start * PAGE_SIZE + node_boot_start);
563 595 }
  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));
564 601  
565 602 /*
566 603 * Reserve the area now: