blob: 5c86ef4c899f25ecbd6449784947bb35b7f4f7c4 [file] [log] [blame]
Thomas Gleixner31e12cb672019-06-01 10:08:49 +02001// SPDX-License-Identifier: GPL-2.0-only
Johannes Weiner454c63b2008-07-25 19:46:07 -07002/*
3 * Generic show_mem() implementation
4 *
5 * Copyright (C) 2008 Johannes Weiner <hannes@saeurebad.de>
Johannes Weiner454c63b2008-07-25 19:46:07 -07006 */
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
Michal Hocko9af744d2017-02-22 15:46:16 -080012void show_mem(unsigned int filter, nodemask_t *nodemask)
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");
Michal Hocko9af744d2017-02-22 15:46:16 -080018 show_free_areas(filter, nodemask);
Johannes Weiner454c63b2008-07-25 19:46:07 -070019
20 for_each_online_pgdat(pgdat) {
Mel Gormanc78e9362013-11-12 15:08:15 -080021 int zoneid;
Johannes Weiner454c63b2008-07-25 19:46:07 -070022
Mel Gormanc78e9362013-11-12 15:08:15 -080023 for (zoneid = 0; zoneid < MAX_NR_ZONES; zoneid++) {
24 struct zone *zone = &pgdat->node_zones[zoneid];
25 if (!populated_zone(zone))
Johannes Weiner454c63b2008-07-25 19:46:07 -070026 continue;
27
Mel Gormanc78e9362013-11-12 15:08:15 -080028 total += zone->present_pages;
Arun KS9705bea2018-12-28 00:34:24 -080029 reserved += zone->present_pages - zone_managed_pages(zone);
Johannes Weiner454c63b2008-07-25 19:46:07 -070030
Mel Gormanc78e9362013-11-12 15:08:15 -080031 if (is_highmem_idx(zoneid))
32 highmem += zone->present_pages;
Johannes Weiner454c63b2008-07-25 19:46:07 -070033 }
Johannes Weiner454c63b2008-07-25 19:46:07 -070034 }
35
Amerigo Wangf047f4f2010-03-05 13:42:24 -080036 printk("%lu pages RAM\n", total);
Mel Gormanc78e9362013-11-12 15:08:15 -080037 printk("%lu pages HighMem/MovableOnly\n", highmem);
Amerigo Wangf047f4f2010-03-05 13:42:24 -080038 printk("%lu pages reserved\n", reserved);
Vishnu Pratap Singh156408c2015-09-08 15:01:19 -070039#ifdef CONFIG_CMA
40 printk("%lu pages cma reserved\n", totalcma_pages);
Vishnu Pratap Singh49abd8c2014-12-18 16:17:21 -080041#endif
Johannes Weiner454c63b2008-07-25 19:46:07 -070042#ifdef CONFIG_QUICKLIST
Amerigo Wangf047f4f2010-03-05 13:42:24 -080043 printk("%lu pages in pagetable cache\n",
Johannes Weiner454c63b2008-07-25 19:46:07 -070044 quicklist_total_size());
45#endif
Xishi Qiu25487d72014-01-21 15:50:57 -080046#ifdef CONFIG_MEMORY_FAILURE
47 printk("%lu pages hwpoisoned\n", atomic_long_read(&num_poisoned_pages));
48#endif
Johannes Weiner454c63b2008-07-25 19:46:07 -070049}