David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 2 | /* |
| 3 | * Generic show_mem() implementation |
| 4 | * |
| 5 | * Copyright (C) 2008 Johannes Weiner <hannes@saeurebad.de> |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <linux/mm.h> |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 9 | #include <linux/cma.h> |
| 10 | |
| 11 | void show_mem(unsigned int filter, nodemask_t *nodemask) |
| 12 | { |
| 13 | pg_data_t *pgdat; |
| 14 | unsigned long total = 0, reserved = 0, highmem = 0; |
| 15 | |
| 16 | printk("Mem-Info:\n"); |
| 17 | show_free_areas(filter, nodemask); |
| 18 | |
| 19 | for_each_online_pgdat(pgdat) { |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 20 | int zoneid; |
| 21 | |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 22 | for (zoneid = 0; zoneid < MAX_NR_ZONES; zoneid++) { |
| 23 | struct zone *zone = &pgdat->node_zones[zoneid]; |
| 24 | if (!populated_zone(zone)) |
| 25 | continue; |
| 26 | |
| 27 | total += zone->present_pages; |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 28 | reserved += zone->present_pages - zone_managed_pages(zone); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 29 | |
| 30 | if (is_highmem_idx(zoneid)) |
| 31 | highmem += zone->present_pages; |
| 32 | } |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 33 | } |
| 34 | |
| 35 | printk("%lu pages RAM\n", total); |
| 36 | printk("%lu pages HighMem/MovableOnly\n", highmem); |
| 37 | printk("%lu pages reserved\n", reserved); |
| 38 | #ifdef CONFIG_CMA |
| 39 | printk("%lu pages cma reserved\n", totalcma_pages); |
| 40 | #endif |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 41 | #ifdef CONFIG_MEMORY_FAILURE |
| 42 | printk("%lu pages hwpoisoned\n", atomic_long_read(&num_poisoned_pages)); |
| 43 | #endif |
| 44 | } |