Thomas Gleixner | 31e12cb67 | 2019-06-01 10:08:49 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Johannes Weiner | 454c63b | 2008-07-25 19:46:07 -0700 | [diff] [blame] | 2 | /* |
| 3 | * Generic show_mem() implementation |
| 4 | * |
| 5 | * Copyright (C) 2008 Johannes Weiner <hannes@saeurebad.de> |
Johannes Weiner | 454c63b | 2008-07-25 19:46:07 -0700 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <linux/mm.h> |
Vishnu Pratap Singh | 49abd8c | 2014-12-18 16:17:21 -0800 | [diff] [blame] | 9 | #include <linux/cma.h> |
Johannes Weiner | 454c63b | 2008-07-25 19:46:07 -0700 | [diff] [blame] | 10 | |
Michal Hocko | 9af744d | 2017-02-22 15:46:16 -0800 | [diff] [blame] | 11 | void show_mem(unsigned int filter, nodemask_t *nodemask) |
Johannes Weiner | 454c63b | 2008-07-25 19:46:07 -0700 | [diff] [blame] | 12 | { |
| 13 | pg_data_t *pgdat; |
Mel Gorman | c78e936 | 2013-11-12 15:08:15 -0800 | [diff] [blame] | 14 | unsigned long total = 0, reserved = 0, highmem = 0; |
Johannes Weiner | 454c63b | 2008-07-25 19:46:07 -0700 | [diff] [blame] | 15 | |
Amerigo Wang | f047f4f | 2010-03-05 13:42:24 -0800 | [diff] [blame] | 16 | printk("Mem-Info:\n"); |
Michal Hocko | 9af744d | 2017-02-22 15:46:16 -0800 | [diff] [blame] | 17 | show_free_areas(filter, nodemask); |
Johannes Weiner | 454c63b | 2008-07-25 19:46:07 -0700 | [diff] [blame] | 18 | |
| 19 | for_each_online_pgdat(pgdat) { |
Mel Gorman | c78e936 | 2013-11-12 15:08:15 -0800 | [diff] [blame] | 20 | int zoneid; |
Johannes Weiner | 454c63b | 2008-07-25 19:46:07 -0700 | [diff] [blame] | 21 | |
Mel Gorman | c78e936 | 2013-11-12 15:08:15 -0800 | [diff] [blame] | 22 | for (zoneid = 0; zoneid < MAX_NR_ZONES; zoneid++) { |
| 23 | struct zone *zone = &pgdat->node_zones[zoneid]; |
| 24 | if (!populated_zone(zone)) |
Johannes Weiner | 454c63b | 2008-07-25 19:46:07 -0700 | [diff] [blame] | 25 | continue; |
| 26 | |
Mel Gorman | c78e936 | 2013-11-12 15:08:15 -0800 | [diff] [blame] | 27 | total += zone->present_pages; |
Arun KS | 9705bea | 2018-12-28 00:34:24 -0800 | [diff] [blame] | 28 | reserved += zone->present_pages - zone_managed_pages(zone); |
Johannes Weiner | 454c63b | 2008-07-25 19:46:07 -0700 | [diff] [blame] | 29 | |
Mel Gorman | c78e936 | 2013-11-12 15:08:15 -0800 | [diff] [blame] | 30 | if (is_highmem_idx(zoneid)) |
| 31 | highmem += zone->present_pages; |
Johannes Weiner | 454c63b | 2008-07-25 19:46:07 -0700 | [diff] [blame] | 32 | } |
Johannes Weiner | 454c63b | 2008-07-25 19:46:07 -0700 | [diff] [blame] | 33 | } |
| 34 | |
Amerigo Wang | f047f4f | 2010-03-05 13:42:24 -0800 | [diff] [blame] | 35 | printk("%lu pages RAM\n", total); |
Mel Gorman | c78e936 | 2013-11-12 15:08:15 -0800 | [diff] [blame] | 36 | printk("%lu pages HighMem/MovableOnly\n", highmem); |
Amerigo Wang | f047f4f | 2010-03-05 13:42:24 -0800 | [diff] [blame] | 37 | printk("%lu pages reserved\n", reserved); |
Vishnu Pratap Singh | 156408c | 2015-09-08 15:01:19 -0700 | [diff] [blame] | 38 | #ifdef CONFIG_CMA |
| 39 | printk("%lu pages cma reserved\n", totalcma_pages); |
Vishnu Pratap Singh | 49abd8c | 2014-12-18 16:17:21 -0800 | [diff] [blame] | 40 | #endif |
Xishi Qiu | 25487d7 | 2014-01-21 15:50:57 -0800 | [diff] [blame] | 41 | #ifdef CONFIG_MEMORY_FAILURE |
| 42 | printk("%lu pages hwpoisoned\n", atomic_long_read(&num_poisoned_pages)); |
| 43 | #endif |
Johannes Weiner | 454c63b | 2008-07-25 19:46:07 -0700 | [diff] [blame] | 44 | } |