show_mem.c 1.27 KB
Newer Older
1 2 3 4 5 6 7 8 9
/*
 * 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/quicklist.h>
10
#include <linux/cma.h>
11

12
void show_mem(unsigned int filter, nodemask_t *nodemask)
13 14
{
	pg_data_t *pgdat;
15
	unsigned long total = 0, reserved = 0, highmem = 0;
16

17
	printk("Mem-Info:\n");
18
	show_free_areas(filter, nodemask);
19 20

	for_each_online_pgdat(pgdat) {
21 22
		unsigned long flags;
		int zoneid;
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))
28 29
				continue;

30
			total += zone->present_pages;
31
			reserved += zone->present_pages - zone->managed_pages;
32

33 34
			if (is_highmem_idx(zoneid))
				highmem += zone->present_pages;
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);
42 43 44
#ifdef CONFIG_CMA
	printk("%lu pages cma reserved\n", totalcma_pages);
#endif
45
#ifdef CONFIG_QUICKLIST
46
	printk("%lu pages in pagetable cache\n",
47 48
		quicklist_total_size());
#endif
49 50 51
#ifdef CONFIG_MEMORY_FAILURE
	printk("%lu pages hwpoisoned\n", atomic_long_read(&num_poisoned_pages));
#endif
52
}