blob: 1feed6a2b12ae6abe2750b18adfa0d4c34327b96 [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>
Johannes Weiner454c63b2008-07-25 19:46:07 -07009#include <linux/quicklist.h>
Vishnu Pratap Singh49abd8c2014-12-18 16:17:21 -080010#include <linux/cma.h>
Johannes Weiner454c63b2008-07-25 19:46:07 -070011
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
20 for_each_online_pgdat(pgdat) {
Mel Gormanc78e9362013-11-12 15:08:15 -080021 unsigned long flags;
22 int zoneid;
Johannes Weiner454c63b2008-07-25 19:46:07 -070023
24 pgdat_resize_lock(pgdat, &flags);
Mel Gormanc78e9362013-11-12 15:08:15 -080025 for (zoneid = 0; zoneid < MAX_NR_ZONES; zoneid++) {
26 struct zone *zone = &pgdat->node_zones[zoneid];
27 if (!populated_zone(zone))
Johannes Weiner454c63b2008-07-25 19:46:07 -070028 continue;
29
Mel Gormanc78e9362013-11-12 15:08:15 -080030 total += zone->present_pages;
Rafael Aquinibc127bd2014-12-02 15:59:22 -080031 reserved += zone->present_pages - zone->managed_pages;
Johannes Weiner454c63b2008-07-25 19:46:07 -070032
Mel Gormanc78e9362013-11-12 15:08:15 -080033 if (is_highmem_idx(zoneid))
34 highmem += zone->present_pages;
Johannes Weiner454c63b2008-07-25 19:46:07 -070035 }
36 pgdat_resize_unlock(pgdat, &flags);
37 }
38
Amerigo Wangf047f4f2010-03-05 13:42:24 -080039 printk("%lu pages RAM\n", total);
Mel Gormanc78e9362013-11-12 15:08:15 -080040 printk("%lu pages HighMem/MovableOnly\n", highmem);
Amerigo Wangf047f4f2010-03-05 13:42:24 -080041 printk("%lu pages reserved\n", reserved);
Vishnu Pratap Singh156408c2015-09-08 15:01:19 -070042#ifdef CONFIG_CMA
43 printk("%lu pages cma reserved\n", totalcma_pages);
Vishnu Pratap Singh49abd8c2014-12-18 16:17:21 -080044#endif
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
Xishi Qiu25487d72014-01-21 15:50:57 -080049#ifdef CONFIG_MEMORY_FAILURE
50 printk("%lu pages hwpoisoned\n", atomic_long_read(&num_poisoned_pages));
51#endif
Johannes Weiner454c63b2008-07-25 19:46:07 -070052}