blob: 1c26c14ffbb9bdfe8d442cb381e7c7d1fd242305 [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>
Vishnu Pratap Singh49abd8c2014-12-18 16:17:21 -08009#include <linux/cma.h>
Johannes Weiner454c63b2008-07-25 19:46:07 -070010
Michal Hocko9af744d2017-02-22 15:46:16 -080011void show_mem(unsigned int filter, nodemask_t *nodemask)
Johannes Weiner454c63b2008-07-25 19:46:07 -070012{
13 pg_data_t *pgdat;
Mel Gormanc78e9362013-11-12 15:08:15 -080014 unsigned long total = 0, reserved = 0, highmem = 0;
Johannes Weiner454c63b2008-07-25 19:46:07 -070015
Amerigo Wangf047f4f2010-03-05 13:42:24 -080016 printk("Mem-Info:\n");
Michal Hocko9af744d2017-02-22 15:46:16 -080017 show_free_areas(filter, nodemask);
Johannes Weiner454c63b2008-07-25 19:46:07 -070018
19 for_each_online_pgdat(pgdat) {
Mel Gormanc78e9362013-11-12 15:08:15 -080020 int zoneid;
Johannes Weiner454c63b2008-07-25 19:46:07 -070021
Mel Gormanc78e9362013-11-12 15:08:15 -080022 for (zoneid = 0; zoneid < MAX_NR_ZONES; zoneid++) {
23 struct zone *zone = &pgdat->node_zones[zoneid];
24 if (!populated_zone(zone))
Johannes Weiner454c63b2008-07-25 19:46:07 -070025 continue;
26
Mel Gormanc78e9362013-11-12 15:08:15 -080027 total += zone->present_pages;
Arun KS9705bea2018-12-28 00:34:24 -080028 reserved += zone->present_pages - zone_managed_pages(zone);
Johannes Weiner454c63b2008-07-25 19:46:07 -070029
Mel Gormanc78e9362013-11-12 15:08:15 -080030 if (is_highmem_idx(zoneid))
31 highmem += zone->present_pages;
Johannes Weiner454c63b2008-07-25 19:46:07 -070032 }
Johannes Weiner454c63b2008-07-25 19:46:07 -070033 }
34
Amerigo Wangf047f4f2010-03-05 13:42:24 -080035 printk("%lu pages RAM\n", total);
Mel Gormanc78e9362013-11-12 15:08:15 -080036 printk("%lu pages HighMem/MovableOnly\n", highmem);
Amerigo Wangf047f4f2010-03-05 13:42:24 -080037 printk("%lu pages reserved\n", reserved);
Vishnu Pratap Singh156408c2015-09-08 15:01:19 -070038#ifdef CONFIG_CMA
39 printk("%lu pages cma reserved\n", totalcma_pages);
Vishnu Pratap Singh49abd8c2014-12-18 16:17:21 -080040#endif
Xishi Qiu25487d72014-01-21 15:50:57 -080041#ifdef CONFIG_MEMORY_FAILURE
42 printk("%lu pages hwpoisoned\n", atomic_long_read(&num_poisoned_pages));
43#endif
Johannes Weiner454c63b2008-07-25 19:46:07 -070044}