diff options
author | Johannes Weiner <hannes@saeurebad.de> | 2008-07-25 22:46:07 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-26 15:00:10 -0400 |
commit | 454c63b02e530f10b4345343f63596dd705888d0 (patch) | |
tree | de7a2aa6e7cd0ce9ab5da615b393c1074e7fe88e /lib | |
parent | 2c97b7fc0d8c8661981beb9517da342ced3b3bc7 (diff) |
lib: generic show_mem()
This implements a platform-independent version of show_mem().
Signed-off-by: Johannes Weiner <hannes@saeurebad.de>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Haavard Skinnemoen <hskinnemoen@atmel.com>
Cc: Bryan Wu <cooloney@kernel.org>
Cc: Chris Zankel <chris@zankel.net>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Jeff Dike <jdike@addtoit.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: David Howells <dhowells@redhat.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Greg Ungerer <gerg@uclinux.org>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Roman Zippel <zippel@linux-m68k.org>
Cc: Hirokazu Takata <takata@linux-m32r.org>
Cc: Mikael Starvik <starvik@axis.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Makefile | 2 | ||||
-rw-r--r-- | lib/show_mem.c | 63 |
2 files changed, 64 insertions, 1 deletions
diff --git a/lib/Makefile b/lib/Makefile index 942c7250f603..3b1f94bbe9de 100644 --- a/lib/Makefile +++ b/lib/Makefile | |||
@@ -11,7 +11,7 @@ lib-y := ctype.o string.o vsprintf.o cmdline.o \ | |||
11 | rbtree.o radix-tree.o dump_stack.o \ | 11 | rbtree.o radix-tree.o dump_stack.o \ |
12 | idr.o int_sqrt.o extable.o prio_tree.o \ | 12 | idr.o int_sqrt.o extable.o prio_tree.o \ |
13 | sha1.o irq_regs.o reciprocal_div.o argv_split.o \ | 13 | sha1.o irq_regs.o reciprocal_div.o argv_split.o \ |
14 | proportions.o prio_heap.o ratelimit.o | 14 | proportions.o prio_heap.o ratelimit.o show_mem.o |
15 | 15 | ||
16 | lib-$(CONFIG_MMU) += ioremap.o | 16 | lib-$(CONFIG_MMU) += ioremap.o |
17 | lib-$(CONFIG_SMP) += cpumask.o | 17 | lib-$(CONFIG_SMP) += cpumask.o |
diff --git a/lib/show_mem.c b/lib/show_mem.c new file mode 100644 index 000000000000..238e72a18ce1 --- /dev/null +++ b/lib/show_mem.c | |||
@@ -0,0 +1,63 @@ | |||
1 | /* | ||
2 | * Generic show_mem() implementation | ||
3 | * | ||
4 | * Copyright (C) 2008 Johannes Weiner <hannes@saeurebad.de> | ||
5 | * All code subject to the GPL version 2. | ||
6 | */ | ||
7 | |||
8 | #include <linux/mm.h> | ||
9 | #include <linux/nmi.h> | ||
10 | #include <linux/quicklist.h> | ||
11 | |||
12 | void show_mem(void) | ||
13 | { | ||
14 | pg_data_t *pgdat; | ||
15 | unsigned long total = 0, reserved = 0, shared = 0, | ||
16 | nonshared = 0, highmem = 0; | ||
17 | |||
18 | printk(KERN_INFO "Mem-Info:\n"); | ||
19 | show_free_areas(); | ||
20 | |||
21 | for_each_online_pgdat(pgdat) { | ||
22 | unsigned long i, flags; | ||
23 | |||
24 | pgdat_resize_lock(pgdat, &flags); | ||
25 | for (i = 0; i < pgdat->node_spanned_pages; i++) { | ||
26 | struct page *page; | ||
27 | unsigned long pfn = pgdat->node_start_pfn + i; | ||
28 | |||
29 | if (unlikely(!(i % MAX_ORDER_NR_PAGES))) | ||
30 | touch_nmi_watchdog(); | ||
31 | |||
32 | if (!pfn_valid(pfn)) | ||
33 | continue; | ||
34 | |||
35 | page = pfn_to_page(pfn); | ||
36 | |||
37 | if (PageHighMem(page)) | ||
38 | highmem++; | ||
39 | |||
40 | if (PageReserved(page)) | ||
41 | reserved++; | ||
42 | else if (page_count(page) == 1) | ||
43 | nonshared++; | ||
44 | else if (page_count(page) > 1) | ||
45 | shared += page_count(page) - 1; | ||
46 | |||
47 | total++; | ||
48 | } | ||
49 | pgdat_resize_unlock(pgdat, &flags); | ||
50 | } | ||
51 | |||
52 | printk(KERN_INFO "%lu pages RAM\n", total); | ||
53 | #ifdef CONFIG_HIGHMEM | ||
54 | printk(KERN_INFO "%lu pages HighMem\n", highmem); | ||
55 | #endif | ||
56 | printk(KERN_INFO "%lu pages reserved\n", reserved); | ||
57 | printk(KERN_INFO "%lu pages shared\n", shared); | ||
58 | printk(KERN_INFO "%lu pages non-shared\n", nonshared); | ||
59 | #ifdef CONFIG_QUICKLIST | ||
60 | printk(KERN_INFO "%lu pages in pagetable cache\n", | ||
61 | quicklist_total_size()); | ||
62 | #endif | ||
63 | } | ||