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 21 22
	if (filter & SHOW_MEM_FILTER_PAGE_COUNT)
		return;

J
Johannes Weiner 已提交
23
	for_each_online_pgdat(pgdat) {
24 25
		unsigned long flags;
		int zoneid;
J
Johannes Weiner 已提交
26 27

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

33 34
			total += zone->present_pages;
			reserved = zone->present_pages - zone->managed_pages;
J
Johannes Weiner 已提交
35

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

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