blob: 5847a4921b8ee25f5fd88624cd74970da371f2ca [file] [log] [blame]
Johannes Weiner454c63b2008-07-25 19:46:07 -07001/*
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 Rientjesb2b755b2011-03-24 15:18:15 -070012void show_mem(unsigned int filter)
Johannes Weiner454c63b2008-07-25 19:46:07 -070013{
14 pg_data_t *pgdat;
Mel Gormanc78e9362013-11-12 15:08:15 -080015 unsigned long total = 0, reserved = 0, highmem = 0;
Johannes Weiner454c63b2008-07-25 19:46:07 -070016
Amerigo Wangf047f4f2010-03-05 13:42:24 -080017 printk("Mem-Info:\n");
David Rientjes7bf02ea2011-05-24 17:11:16 -070018 show_free_areas(filter);
Johannes Weiner454c63b2008-07-25 19:46:07 -070019
David Rientjes4b59e6c2013-04-29 15:06:11 -070020 if (filter & SHOW_MEM_FILTER_PAGE_COUNT)
21 return;
22
Johannes Weiner454c63b2008-07-25 19:46:07 -070023 for_each_online_pgdat(pgdat) {
Mel Gormanc78e9362013-11-12 15:08:15 -080024 unsigned long flags;
25 int zoneid;
Johannes Weiner454c63b2008-07-25 19:46:07 -070026
27 pgdat_resize_lock(pgdat, &flags);
Mel Gormanc78e9362013-11-12 15:08:15 -080028 for (zoneid = 0; zoneid < MAX_NR_ZONES; zoneid++) {
29 struct zone *zone = &pgdat->node_zones[zoneid];
30 if (!populated_zone(zone))
Johannes Weiner454c63b2008-07-25 19:46:07 -070031 continue;
32
Mel Gormanc78e9362013-11-12 15:08:15 -080033 total += zone->present_pages;
34 reserved = zone->present_pages - zone->managed_pages;
Johannes Weiner454c63b2008-07-25 19:46:07 -070035
Mel Gormanc78e9362013-11-12 15:08:15 -080036 if (is_highmem_idx(zoneid))
37 highmem += zone->present_pages;
Johannes Weiner454c63b2008-07-25 19:46:07 -070038 }
39 pgdat_resize_unlock(pgdat, &flags);
40 }
41
Amerigo Wangf047f4f2010-03-05 13:42:24 -080042 printk("%lu pages RAM\n", total);
Mel Gormanc78e9362013-11-12 15:08:15 -080043 printk("%lu pages HighMem/MovableOnly\n", highmem);
Amerigo Wangf047f4f2010-03-05 13:42:24 -080044 printk("%lu pages reserved\n", reserved);
Johannes Weiner454c63b2008-07-25 19:46:07 -070045#ifdef CONFIG_QUICKLIST
Amerigo Wangf047f4f2010-03-05 13:42:24 -080046 printk("%lu pages in pagetable cache\n",
Johannes Weiner454c63b2008-07-25 19:46:07 -070047 quicklist_total_size());
48#endif
49}