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; |
Mel Gorman | c78e936 | 2013-11-12 15:08:15 -0800 | [diff] [blame^] | 15 | unsigned long total = 0, reserved = 0, highmem = 0; |
Johannes Weiner | 454c63b | 2008-07-25 19:46:07 -0700 | [diff] [blame] | 16 | |
Amerigo Wang | f047f4f | 2010-03-05 13:42:24 -0800 | [diff] [blame] | 17 | printk("Mem-Info:\n"); |
David Rientjes | 7bf02ea | 2011-05-24 17:11:16 -0700 | [diff] [blame] | 18 | show_free_areas(filter); |
Johannes Weiner | 454c63b | 2008-07-25 19:46:07 -0700 | [diff] [blame] | 19 | |
David Rientjes | 4b59e6c | 2013-04-29 15:06:11 -0700 | [diff] [blame] | 20 | if (filter & SHOW_MEM_FILTER_PAGE_COUNT) |
| 21 | return; |
| 22 | |
Johannes Weiner | 454c63b | 2008-07-25 19:46:07 -0700 | [diff] [blame] | 23 | for_each_online_pgdat(pgdat) { |
Mel Gorman | c78e936 | 2013-11-12 15:08:15 -0800 | [diff] [blame^] | 24 | unsigned long flags; |
| 25 | int zoneid; |
Johannes Weiner | 454c63b | 2008-07-25 19:46:07 -0700 | [diff] [blame] | 26 | |
| 27 | pgdat_resize_lock(pgdat, &flags); |
Mel Gorman | c78e936 | 2013-11-12 15:08:15 -0800 | [diff] [blame^] | 28 | for (zoneid = 0; zoneid < MAX_NR_ZONES; zoneid++) { |
| 29 | struct zone *zone = &pgdat->node_zones[zoneid]; |
| 30 | if (!populated_zone(zone)) |
Johannes Weiner | 454c63b | 2008-07-25 19:46:07 -0700 | [diff] [blame] | 31 | continue; |
| 32 | |
Mel Gorman | c78e936 | 2013-11-12 15:08:15 -0800 | [diff] [blame^] | 33 | total += zone->present_pages; |
| 34 | reserved = zone->present_pages - zone->managed_pages; |
Johannes Weiner | 454c63b | 2008-07-25 19:46:07 -0700 | [diff] [blame] | 35 | |
Mel Gorman | c78e936 | 2013-11-12 15:08:15 -0800 | [diff] [blame^] | 36 | if (is_highmem_idx(zoneid)) |
| 37 | highmem += zone->present_pages; |
Johannes Weiner | 454c63b | 2008-07-25 19:46:07 -0700 | [diff] [blame] | 38 | } |
| 39 | pgdat_resize_unlock(pgdat, &flags); |
| 40 | } |
| 41 | |
Amerigo Wang | f047f4f | 2010-03-05 13:42:24 -0800 | [diff] [blame] | 42 | printk("%lu pages RAM\n", total); |
Mel Gorman | c78e936 | 2013-11-12 15:08:15 -0800 | [diff] [blame^] | 43 | printk("%lu pages HighMem/MovableOnly\n", highmem); |
Amerigo Wang | f047f4f | 2010-03-05 13:42:24 -0800 | [diff] [blame] | 44 | printk("%lu pages reserved\n", reserved); |
Johannes Weiner | 454c63b | 2008-07-25 19:46:07 -0700 | [diff] [blame] | 45 | #ifdef CONFIG_QUICKLIST |
Amerigo Wang | f047f4f | 2010-03-05 13:42:24 -0800 | [diff] [blame] | 46 | printk("%lu pages in pagetable cache\n", |
Johannes Weiner | 454c63b | 2008-07-25 19:46:07 -0700 | [diff] [blame] | 47 | quicklist_total_size()); |
| 48 | #endif |
| 49 | } |