Blame view

lib/show_mem.c 1.3 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

b2b755b5f   David Rientjes   lib, arch: add fi...
12
  void show_mem(unsigned int filter)
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:
  ");
7bf02ea22   David Rientjes   arch, mm: filter ...
19
  	show_free_areas(filter);
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);
49abd8c28   Vishnu Pratap Singh   lib/show_mem.c: a...
42
43
44
45
46
47
  #ifdef CONFIG_CMA
  	printk("%lu pages reserved
  ", (reserved - totalcma_pages));
  	printk("%lu pages cma reserved
  ", totalcma_pages);
  #else
f047f4f37   Amerigo Wang   mm: use the same ...
48
49
  	printk("%lu pages reserved
  ", reserved);
49abd8c28   Vishnu Pratap Singh   lib/show_mem.c: a...
50
  #endif
454c63b02   Johannes Weiner   lib: generic show...
51
  #ifdef CONFIG_QUICKLIST
f047f4f37   Amerigo Wang   mm: use the same ...
52
53
  	printk("%lu pages in pagetable cache
  ",
454c63b02   Johannes Weiner   lib: generic show...
54
55
  		quicklist_total_size());
  #endif
25487d73a   Xishi Qiu   lib/show_mem.c: s...
56
57
58
59
  #ifdef CONFIG_MEMORY_FAILURE
  	printk("%lu pages hwpoisoned
  ", atomic_long_read(&num_poisoned_pages));
  #endif
454c63b02   Johannes Weiner   lib: generic show...
60
  }