# HG changeset patch # User yamahata@xxxxxxxxxxxxx # Date 1180517294 -32400 # Node ID ab001aaf06238e6e112fc6133c3d2ed1e0583c7b # Parent 32c3fe2830af8c7ff7bde90b8e46b970680bb766 add debug function. PATCHNAME: debug_dump_heap Signed-off-by: Isaku Yamahata diff -r 32c3fe2830af -r ab001aaf0623 xen/common/page_alloc.c --- a/xen/common/page_alloc.c Wed May 30 18:27:25 2007 +0900 +++ b/xen/common/page_alloc.c Wed May 30 18:28:14 2007 +0900 @@ -1088,6 +1088,45 @@ static __init int page_scrub_init(void) } __initcall(page_scrub_init); + +static int opt_print_all_avail; +boolean_param("print_all_avail", opt_print_all_avail); +static int opt_print_heap; +boolean_param("print_heap", opt_print_heap); +static int opt_print_all_heap; +boolean_param("print_all_heap", opt_print_all_heap); +void __dump_heap_avail(const char* func, int line) +{ + unsigned int node; + + printk("%s:%d dumping heap max 0x%lx tot 0x%lx\n", + func, line, dom0->max_pages, dom0->tot_pages); + for ( node = 0; node < MAX_NUMNODES; node++ ) + { + unsigned int zone; + if ( !avail[node] ) + continue; + for ( zone = 0; zone < NR_ZONES; zone++ ) { + unsigned int order; + if (avail[node][zone] > 0 || opt_print_all_avail) + printk("heap[node=%d][zone=%d] -> %lu pages\n", + node, zone, avail[node][zone]); + + if (!opt_print_heap) + continue; + for ( order = 0; order < MAX_ORDER; order++ ) { + struct page_info *page; + unsigned int n = 0; + list_for_each_entry(page, &heap(node, zone, order), list) + n++; + if (n > 0 || opt_print_all_heap) + printk("list[node=%d][zone=%d][order=%d] = %d\n", + node, zone, order, n); + } + } + } +} + /* * Local variables: * mode: C diff -r 32c3fe2830af -r ab001aaf0623 xen/include/xen/mm.h --- a/xen/include/xen/mm.h Wed May 30 18:27:25 2007 +0900 +++ b/xen/include/xen/mm.h Wed May 30 18:28:14 2007 +0900 @@ -106,4 +106,7 @@ int guest_remove_page(struct domain *d, /* Returns TRUE if the memory at address @p is ordinary RAM. */ int memory_is_conventional_ram(paddr_t p); +void __dump_heap_avail(const char* func, int line); +#define dump_heap_avail() __dump_heap_avail(__func__, __LINE__) + #endif /* __XEN_MM_H__ */