Blame view

lib/show_mem.c 1.16 KB
454c63b02   Johannes Weiner   lib: generic show...
1
2
3
4
5
6
7
8
9
10
  /*
   * Generic show_mem() implementation
   *
   * Copyright (C) 2008 Johannes Weiner <hannes@saeurebad.de>
   * All code subject to the GPL version 2.
   */
  
  #include <linux/mm.h>
  #include <linux/nmi.h>
  #include <linux/quicklist.h>
b2b755b5f   David Rientjes   lib, arch: add fi...
11
  void show_mem(unsigned int filter)
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:
  ");
7bf02ea22   David Rientjes   arch, mm: filter ...
18
  	show_free_areas(filter);
454c63b02   Johannes Weiner   lib: generic show...
19
20
  
  	for_each_online_pgdat(pgdat) {
c78e93630   Mel Gorman   mm: do not walk a...
21
22
  		unsigned long flags;
  		int zoneid;
454c63b02   Johannes Weiner   lib: generic show...
23
24
  
  		pgdat_resize_lock(pgdat, &flags);
c78e93630   Mel Gorman   mm: do not walk a...
25
26
27
  		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...
28
  				continue;
c78e93630   Mel Gorman   mm: do not walk a...
29
30
  			total += zone->present_pages;
  			reserved = zone->present_pages - zone->managed_pages;
454c63b02   Johannes Weiner   lib: generic show...
31

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