show_mem.c 1.1 KB
Newer Older
J
Johannes Weiner 已提交
1 2 3 4 5 6 7 8 9 10 11
/*
 * Generic show_mem() implementation
 *
 * Copyright (C) 2008 Johannes Weiner <hannes@saeurebad.de>
 * All code subject to the GPL version 2.
 */

#include <linux/mm.h>
#include <linux/nmi.h>
#include <linux/quicklist.h>

12
void show_mem(unsigned int filter)
J
Johannes Weiner 已提交
13 14
{
	pg_data_t *pgdat;
15
	unsigned long total = 0, reserved = 0, highmem = 0;
J
Johannes Weiner 已提交
16

17
	printk("Mem-Info:\n");
18
	show_free_areas(filter);
J
Johannes Weiner 已提交
19 20

	for_each_online_pgdat(pgdat) {
21 22
		unsigned long flags;
		int zoneid;
J
Johannes Weiner 已提交
23 24

		pgdat_resize_lock(pgdat, &flags);
25 26 27
		for (zoneid = 0; zoneid < MAX_NR_ZONES; zoneid++) {
			struct zone *zone = &pgdat->node_zones[zoneid];
			if (!populated_zone(zone))
J
Johannes Weiner 已提交
28 29
				continue;

30 31
			total += zone->present_pages;
			reserved = zone->present_pages - zone->managed_pages;
J
Johannes Weiner 已提交
32

33 34
			if (is_highmem_idx(zoneid))
				highmem += zone->present_pages;
J
Johannes Weiner 已提交
35 36 37 38
		}
		pgdat_resize_unlock(pgdat, &flags);
	}

39
	printk("%lu pages RAM\n", total);
40
	printk("%lu pages HighMem/MovableOnly\n", highmem);
41
	printk("%lu pages reserved\n", reserved);
J
Johannes Weiner 已提交
42
#ifdef CONFIG_QUICKLIST
43
	printk("%lu pages in pagetable cache\n",
J
Johannes Weiner 已提交
44 45 46
		quicklist_total_size());
#endif
}