Blame view

lib/show_mem.c 1.27 KB
454c63b02   Johannes Weiner   lib: generic show...
1
2
3
4
5
6
7
8
  /*
   * Generic show_mem() implementation
   *
   * Copyright (C) 2008 Johannes Weiner <hannes@saeurebad.de>
   * All code subject to the GPL version 2.
   */
  
  #include <linux/mm.h>
454c63b02   Johannes Weiner   lib: generic show...
9
  #include <linux/quicklist.h>
49abd8c28   Vishnu Pratap Singh   lib/show_mem.c: a...
10
  #include <linux/cma.h>
454c63b02   Johannes Weiner   lib: generic show...
11

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

f047f4f37   Amerigo Wang   mm: use the same ...
17
18
  	printk("Mem-Info:
  ");
9af744d74   Michal Hocko   lib/show_mem.c: t...
19
  	show_free_areas(filter, nodemask);
454c63b02   Johannes Weiner   lib: generic show...
20
21
  
  	for_each_online_pgdat(pgdat) {
c78e93630   Mel Gorman   mm: do not walk a...
22
23
  		unsigned long flags;
  		int zoneid;
454c63b02   Johannes Weiner   lib: generic show...
24
25
  
  		pgdat_resize_lock(pgdat, &flags);
c78e93630   Mel Gorman   mm: do not walk a...
26
27
28
  		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...
29
  				continue;
c78e93630   Mel Gorman   mm: do not walk a...
30
  			total += zone->present_pages;
bc127bda3   Rafael Aquini   mm: do not overwr...
31
  			reserved += zone->present_pages - zone->managed_pages;
454c63b02   Johannes Weiner   lib: generic show...
32

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