diff -urNp c/fs/proc/proc_misc.c b/fs/proc/proc_misc.c --- c/fs/proc/proc_misc.c Wed Jul 31 01:17:41 2002 +++ b/fs/proc/proc_misc.c Tue Jul 30 17:17:02 2002 @@ -64,6 +64,9 @@ extern int get_swaparea_info (char *); #ifdef CONFIG_SGI_DS1286 extern int get_ds1286_status(char *); #endif +#ifdef CONFIG_DISCONTIGMEM +extern int get_discontig_info(char *); +#endif static int proc_calc_metrics(char *page, char **start, off_t off, int count, int *eof, int len) @@ -396,6 +399,15 @@ static int execdomains_read_proc(char *p return proc_calc_metrics(page, start, off, count, eof, len); } +#ifdef CONFIG_DISCONTIGMEM +static int discontig_read_proc(char *page, char **start, off_t off, + int count, int *eof, void *data) +{ + int len = get_discontig_info(page); + return proc_calc_metrics(page, start, off, count, eof, len); +} +#endif + static int swaps_read_proc(char *page, char **start, off_t off, int count, int *eof, void *data) { @@ -526,6 +538,9 @@ void __init proc_misc_init(void) {"swaps", swaps_read_proc}, {"iomem", memory_read_proc}, {"execdomains", execdomains_read_proc}, +#ifdef CONFIG_DISCONTIGMEM + {"discontig", discontig_read_proc}, +#endif {NULL,} }; for (p = simple_ones; p->name; p++) diff -urNp c/mm/numa.c b/mm/numa.c --- c/mm/numa.c Wed Jul 31 01:18:23 2002 +++ b/mm/numa.c Wed Jul 31 01:16:04 2002 @@ -127,4 +127,49 @@ struct page * _alloc_pages(unsigned int return(0); } +int get_discontig_info(char * page) +{ + char *start = page; + int i, nid; + int reserved, cached, slab, free, active; + pg_data_t *pgdat; + zone_t *zone; + + page += sprintf(page, "%4s %7s %7s %9s %7s %7s %7s\n", "node","total","free","reserved","swap","slab","active"); + + /* + * Iterate over each node's pg_data_t and look at its pages + */ + for(nid = 0; nid < numnodes; nid++) { + pgdat = NODE_DATA(nid); + reserved = cached = slab = free = active = 0; + + /* + * Get info about each page in the node + */ + page += sprintf(page, "%4d ", pgdat->node_id); + for(i = 0; i < pgdat->node_size; i++) { + if (PageReserved(pgdat->node_mem_map + i)) + reserved++; + if (PageSwapCache(pgdat->node_mem_map + i)) + cached++; + if (PageSlab(pgdat->node_mem_map + i)) + slab++; + if (PageActive(pgdat->node_mem_map + i)) + active++; + } + for (zone = pgdat->node_zones; zone < pgdat->node_zones + MAX_NR_ZONES; zone++) + free += zone->free_pages; + + page += sprintf(page, "%7ld ", pgdat->node_size); + page += sprintf(page, "%7d ", free); + page += sprintf(page, "%9d ", reserved); + page += sprintf(page, "%7d ", cached); + page += sprintf(page, "%7d ", slab); + page += sprintf(page, "%7d\n", active); + } + + return page - start; +} + #endif /* CONFIG_DISCONTIGMEM */