Blame view

lib/show_mem.c 1.05 KB
31e12cb67   Thomas Gleixner   treewide: Replace...
1
  // SPDX-License-Identifier: GPL-2.0-only
454c63b02   Johannes Weiner   lib: generic show...
2
3
4
5
  /*
   * Generic show_mem() implementation
   *
   * Copyright (C) 2008 Johannes Weiner <hannes@saeurebad.de>
454c63b02   Johannes Weiner   lib: generic show...
6
7
8
   */
  
  #include <linux/mm.h>
49abd8c28   Vishnu Pratap Singh   lib/show_mem.c: a...
9
  #include <linux/cma.h>
454c63b02   Johannes Weiner   lib: generic show...
10

9af744d74   Michal Hocko   lib/show_mem.c: t...
11
  void show_mem(unsigned int filter, nodemask_t *nodemask)
454c63b02   Johannes Weiner   lib: generic show...
12
13
  {
  	pg_data_t *pgdat;
c78e93630   Mel Gorman   mm: do not walk a...
14
  	unsigned long total = 0, reserved = 0, highmem = 0;
454c63b02   Johannes Weiner   lib: generic show...
15

f047f4f37   Amerigo Wang   mm: use the same ...
16
17
  	printk("Mem-Info:
  ");
9af744d74   Michal Hocko   lib/show_mem.c: t...
18
  	show_free_areas(filter, nodemask);
454c63b02   Johannes Weiner   lib: generic show...
19
20
  
  	for_each_online_pgdat(pgdat) {
c78e93630   Mel Gorman   mm: do not walk a...
21
  		int zoneid;
454c63b02   Johannes Weiner   lib: generic show...
22

c78e93630   Mel Gorman   mm: do not walk a...
23
24
25
  		for (zoneid = 0; zoneid < MAX_NR_ZONES; zoneid++) {
  			struct zone *zone = &pgdat->node_zones[zoneid];
  			if (!populated_zone(zone))
454c63b02   Johannes Weiner   lib: generic show...
26
  				continue;
c78e93630   Mel Gorman   mm: do not walk a...
27
  			total += zone->present_pages;
9705bea5f   Arun KS   mm: convert zone-...
28
  			reserved += zone->present_pages - zone_managed_pages(zone);
454c63b02   Johannes Weiner   lib: generic show...
29

c78e93630   Mel Gorman   mm: do not walk a...
30
31
  			if (is_highmem_idx(zoneid))
  				highmem += zone->present_pages;
454c63b02   Johannes Weiner   lib: generic show...
32
  		}
454c63b02   Johannes Weiner   lib: generic show...
33
  	}
f047f4f37   Amerigo Wang   mm: use the same ...
34
35
  	printk("%lu pages RAM
  ", total);
c78e93630   Mel Gorman   mm: do not walk a...
36
37
  	printk("%lu pages HighMem/MovableOnly
  ", highmem);
156408c0e   Vishnu Pratap Singh   lib/show_mem.c: c...
38
39
  	printk("%lu pages reserved
  ", reserved);
49abd8c28   Vishnu Pratap Singh   lib/show_mem.c: a...
40
  #ifdef CONFIG_CMA
49abd8c28   Vishnu Pratap Singh   lib/show_mem.c: a...
41
42
  	printk("%lu pages cma reserved
  ", totalcma_pages);
49abd8c28   Vishnu Pratap Singh   lib/show_mem.c: a...
43
  #endif
25487d73a   Xishi Qiu   lib/show_mem.c: s...
44
45
46
47
  #ifdef CONFIG_MEMORY_FAILURE
  	printk("%lu pages hwpoisoned
  ", atomic_long_read(&num_poisoned_pages));
  #endif
454c63b02   Johannes Weiner   lib: generic show...
48
  }