Merge tag 'ntb-5.3' of git://github.com/jonmason/ntb
[platform/kernel/linux-rpi.git] / lib / show_mem.c
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * Generic show_mem() implementation
4  *
5  * Copyright (C) 2008 Johannes Weiner <hannes@saeurebad.de>
6  */
7
8 #include <linux/mm.h>
9 #include <linux/quicklist.h>
10 #include <linux/cma.h>
11
12 void show_mem(unsigned int filter, nodemask_t *nodemask)
13 {
14         pg_data_t *pgdat;
15         unsigned long total = 0, reserved = 0, highmem = 0;
16
17         printk("Mem-Info:\n");
18         show_free_areas(filter, nodemask);
19
20         for_each_online_pgdat(pgdat) {
21                 int zoneid;
22
23                 for (zoneid = 0; zoneid < MAX_NR_ZONES; zoneid++) {
24                         struct zone *zone = &pgdat->node_zones[zoneid];
25                         if (!populated_zone(zone))
26                                 continue;
27
28                         total += zone->present_pages;
29                         reserved += zone->present_pages - zone_managed_pages(zone);
30
31                         if (is_highmem_idx(zoneid))
32                                 highmem += zone->present_pages;
33                 }
34         }
35
36         printk("%lu pages RAM\n", total);
37         printk("%lu pages HighMem/MovableOnly\n", highmem);
38         printk("%lu pages reserved\n", reserved);
39 #ifdef CONFIG_CMA
40         printk("%lu pages cma reserved\n", totalcma_pages);
41 #endif
42 #ifdef CONFIG_QUICKLIST
43         printk("%lu pages in pagetable cache\n",
44                 quicklist_total_size());
45 #endif
46 #ifdef CONFIG_MEMORY_FAILURE
47         printk("%lu pages hwpoisoned\n", atomic_long_read(&num_poisoned_pages));
48 #endif
49 }