blob: 7de89f4a36cfa54dd01980898a4646f7c41ec550 [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>
Vishnu Pratap Singh49abd8c2014-12-18 16:17:21 -080011#include <linux/cma.h>
Johannes Weiner454c63b2008-07-25 19:46:07 -070012
David Rientjesb2b755b2011-03-24 15:18:15 -070013void show_mem(unsigned int filter)
Johannes Weiner454c63b2008-07-25 19:46:07 -070014{
15 pg_data_t *pgdat;
Mel Gormanc78e9362013-11-12 15:08:15 -080016 unsigned long total = 0, reserved = 0, highmem = 0;
Johannes Weiner454c63b2008-07-25 19:46:07 -070017
Amerigo Wangf047f4f2010-03-05 13:42:24 -080018 printk("Mem-Info:\n");
David Rientjes7bf02ea2011-05-24 17:11:16 -070019 show_free_areas(filter);
Johannes Weiner454c63b2008-07-25 19:46:07 -070020
21 for_each_online_pgdat(pgdat) {
Mel Gormanc78e9362013-11-12 15:08:15 -080022 unsigned long flags;
23 int zoneid;
Johannes Weiner454c63b2008-07-25 19:46:07 -070024
25 pgdat_resize_lock(pgdat, &flags);
Mel Gormanc78e9362013-11-12 15:08:15 -080026 for (zoneid = 0; zoneid < MAX_NR_ZONES; zoneid++) {
27 struct zone *zone = &pgdat->node_zones[zoneid];
28 if (!populated_zone(zone))
Johannes Weiner454c63b2008-07-25 19:46:07 -070029 continue;
30
Mel Gormanc78e9362013-11-12 15:08:15 -080031 total += zone->present_pages;
Rafael Aquinibc127bd2014-12-02 15:59:22 -080032 reserved += zone->present_pages - zone->managed_pages;
Johannes Weiner454c63b2008-07-25 19:46:07 -070033
Mel Gormanc78e9362013-11-12 15:08:15 -080034 if (is_highmem_idx(zoneid))
35 highmem += zone->present_pages;
Johannes Weiner454c63b2008-07-25 19:46:07 -070036 }
37 pgdat_resize_unlock(pgdat, &flags);
38 }
39
Amerigo Wangf047f4f2010-03-05 13:42:24 -080040 printk("%lu pages RAM\n", total);
Mel Gormanc78e9362013-11-12 15:08:15 -080041 printk("%lu pages HighMem/MovableOnly\n", highmem);
Vishnu Pratap Singh49abd8c2014-12-18 16:17:21 -080042#ifdef CONFIG_CMA
43 printk("%lu pages reserved\n", (reserved - totalcma_pages));
44 printk("%lu pages cma reserved\n", totalcma_pages);
45#else
Amerigo Wangf047f4f2010-03-05 13:42:24 -080046 printk("%lu pages reserved\n", reserved);
Vishnu Pratap Singh49abd8c2014-12-18 16:17:21 -080047#endif
Johannes Weiner454c63b2008-07-25 19:46:07 -070048#ifdef CONFIG_QUICKLIST
Amerigo Wangf047f4f2010-03-05 13:42:24 -080049 printk("%lu pages in pagetable cache\n",
Johannes Weiner454c63b2008-07-25 19:46:07 -070050 quicklist_total_size());
51#endif
Xishi Qiu25487d72014-01-21 15:50:57 -080052#ifdef CONFIG_MEMORY_FAILURE
53 printk("%lu pages hwpoisoned\n", atomic_long_read(&num_poisoned_pages));
54#endif
Johannes Weiner454c63b2008-07-25 19:46:07 -070055}