Johannes Weiner | 454c63b | 2008-07-25 19:46:07 -0700 | [diff] [blame] | 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 | |
David Rientjes | b2b755b | 2011-03-24 15:18:15 -0700 | [diff] [blame] | 12 | void show_mem(unsigned int filter) |
Johannes Weiner | 454c63b | 2008-07-25 19:46:07 -0700 | [diff] [blame] | 13 | { |
| 14 | pg_data_t *pgdat; |
| 15 | unsigned long total = 0, reserved = 0, shared = 0, |
| 16 | nonshared = 0, highmem = 0; |
| 17 | |
Amerigo Wang | f047f4f | 2010-03-05 13:42:24 -0800 | [diff] [blame] | 18 | printk("Mem-Info:\n"); |
David Rientjes | ddd588b | 2011-03-22 16:30:46 -0700 | [diff] [blame] | 19 | __show_free_areas(filter); |
Johannes Weiner | 454c63b | 2008-07-25 19:46:07 -0700 | [diff] [blame] | 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 | |
Amerigo Wang | f047f4f | 2010-03-05 13:42:24 -0800 | [diff] [blame] | 52 | printk("%lu pages RAM\n", total); |
Johannes Weiner | 454c63b | 2008-07-25 19:46:07 -0700 | [diff] [blame] | 53 | #ifdef CONFIG_HIGHMEM |
Amerigo Wang | f047f4f | 2010-03-05 13:42:24 -0800 | [diff] [blame] | 54 | printk("%lu pages HighMem\n", highmem); |
Johannes Weiner | 454c63b | 2008-07-25 19:46:07 -0700 | [diff] [blame] | 55 | #endif |
Amerigo Wang | f047f4f | 2010-03-05 13:42:24 -0800 | [diff] [blame] | 56 | printk("%lu pages reserved\n", reserved); |
| 57 | printk("%lu pages shared\n", shared); |
| 58 | printk("%lu pages non-shared\n", nonshared); |
Johannes Weiner | 454c63b | 2008-07-25 19:46:07 -0700 | [diff] [blame] | 59 | #ifdef CONFIG_QUICKLIST |
Amerigo Wang | f047f4f | 2010-03-05 13:42:24 -0800 | [diff] [blame] | 60 | printk("%lu pages in pagetable cache\n", |
Johannes Weiner | 454c63b | 2008-07-25 19:46:07 -0700 | [diff] [blame] | 61 | quicklist_total_size()); |
| 62 | #endif |
| 63 | } |