Blame view
fs/proc/meminfo.c
4.9 KB
e1759c215
|
1 |
#include <linux/fs.h> |
e1759c215
|
2 3 4 |
#include <linux/init.h> #include <linux/kernel.h> #include <linux/mm.h> |
cb900f412
|
5 |
#include <linux/hugetlb.h> |
e1759c215
|
6 7 8 9 10 11 12 |
#include <linux/mman.h> #include <linux/mmzone.h> #include <linux/proc_fs.h> #include <linux/quicklist.h> #include <linux/seq_file.h> #include <linux/swap.h> #include <linux/vmstat.h> |
60063497a
|
13 |
#include <linux/atomic.h> |
db3808c1b
|
14 |
#include <linux/vmalloc.h> |
47f8f9297
|
15 16 17 |
#ifdef CONFIG_CMA #include <linux/cma.h> #endif |
e1759c215
|
18 19 20 21 22 23 24 25 26 27 28 29 |
#include <asm/page.h> #include <asm/pgtable.h> #include "internal.h" void __attribute__((weak)) arch_report_meminfo(struct seq_file *m) { } static int meminfo_proc_show(struct seq_file *m, void *v) { struct sysinfo i; unsigned long committed; |
e1759c215
|
30 |
long cached; |
34e431b0a
|
31 |
long available; |
e1759c215
|
32 33 34 35 36 37 38 39 40 |
unsigned long pages[NR_LRU_LISTS]; int lru; /* * display in kilobytes. */ #define K(x) ((x) << (PAGE_SHIFT - 10)) si_meminfo(&i); si_swapinfo(&i); |
00a62ce91
|
41 |
committed = percpu_counter_read_positive(&vm_committed_as); |
e1759c215
|
42 43 |
cached = global_page_state(NR_FILE_PAGES) - |
33806f06d
|
44 |
total_swapcache_pages() - i.bufferram; |
e1759c215
|
45 46 |
if (cached < 0) cached = 0; |
e1759c215
|
47 48 |
for (lru = LRU_BASE; lru < NR_LRU_LISTS; lru++) pages[lru] = global_page_state(NR_LRU_BASE + lru); |
d02bd27bd
|
49 |
available = si_mem_available(); |
34e431b0a
|
50 |
|
e1759c215
|
51 52 53 54 55 56 57 58 |
/* * Tagged format, for easy grepping and expansion. */ seq_printf(m, "MemTotal: %8lu kB " "MemFree: %8lu kB " |
34e431b0a
|
59 60 |
"MemAvailable: %8lu kB " |
e1759c215
|
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
"Buffers: %8lu kB " "Cached: %8lu kB " "SwapCached: %8lu kB " "Active: %8lu kB " "Inactive: %8lu kB " "Active(anon): %8lu kB " "Inactive(anon): %8lu kB " "Active(file): %8lu kB " "Inactive(file): %8lu kB " |
e1759c215
|
79 80 81 82 |
"Unevictable: %8lu kB " "Mlocked: %8lu kB " |
e1759c215
|
83 84 85 86 87 88 89 90 91 92 |
#ifdef CONFIG_HIGHMEM "HighTotal: %8lu kB " "HighFree: %8lu kB " "LowTotal: %8lu kB " "LowFree: %8lu kB " #endif |
8feae1311
|
93 94 95 96 |
#ifndef CONFIG_MMU "MmapCopy: %8lu kB " #endif |
e1759c215
|
97 98 99 100 101 102 103 104 105 106 107 108 |
"SwapTotal: %8lu kB " "SwapFree: %8lu kB " "Dirty: %8lu kB " "Writeback: %8lu kB " "AnonPages: %8lu kB " "Mapped: %8lu kB " |
4b02108ac
|
109 110 |
"Shmem: %8lu kB " |
e1759c215
|
111 112 113 114 115 116 |
"Slab: %8lu kB " "SReclaimable: %8lu kB " "SUnreclaim: %8lu kB " |
c6a7f5728
|
117 118 |
"KernelStack: %8lu kB " |
e1759c215
|
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
"PageTables: %8lu kB " #ifdef CONFIG_QUICKLIST "Quicklists: %8lu kB " #endif "NFS_Unstable: %8lu kB " "Bounce: %8lu kB " "WritebackTmp: %8lu kB " "CommitLimit: %8lu kB " "Committed_AS: %8lu kB " "VmallocTotal: %8lu kB " "VmallocUsed: %8lu kB " |
6a46079cf
|
139 140 141 |
"VmallocChunk: %8lu kB " #ifdef CONFIG_MEMORY_FAILURE |
370c28def
|
142 143 |
"HardwareCorrupted: %5lu kB " |
6a46079cf
|
144 |
#endif |
79134171d
|
145 146 147 148 |
#ifdef CONFIG_TRANSPARENT_HUGEPAGE "AnonHugePages: %8lu kB " #endif |
47f8f9297
|
149 150 151 152 153 154 |
#ifdef CONFIG_CMA "CmaTotal: %8lu kB " "CmaFree: %8lu kB " #endif |
6a46079cf
|
155 |
, |
e1759c215
|
156 157 |
K(i.totalram), K(i.freeram), |
34e431b0a
|
158 |
K(available), |
e1759c215
|
159 160 |
K(i.bufferram), K(cached), |
33806f06d
|
161 |
K(total_swapcache_pages()), |
e1759c215
|
162 163 164 165 166 167 |
K(pages[LRU_ACTIVE_ANON] + pages[LRU_ACTIVE_FILE]), K(pages[LRU_INACTIVE_ANON] + pages[LRU_INACTIVE_FILE]), K(pages[LRU_ACTIVE_ANON]), K(pages[LRU_INACTIVE_ANON]), K(pages[LRU_ACTIVE_FILE]), K(pages[LRU_INACTIVE_FILE]), |
e1759c215
|
168 169 |
K(pages[LRU_UNEVICTABLE]), K(global_page_state(NR_MLOCK)), |
e1759c215
|
170 171 172 173 174 175 |
#ifdef CONFIG_HIGHMEM K(i.totalhigh), K(i.freehigh), K(i.totalram-i.totalhigh), K(i.freeram-i.freehigh), #endif |
8feae1311
|
176 |
#ifndef CONFIG_MMU |
33e5d7697
|
177 |
K((unsigned long) atomic_long_read(&mmap_pages_allocated)), |
8feae1311
|
178 |
#endif |
e1759c215
|
179 180 181 182 |
K(i.totalswap), K(i.freeswap), K(global_page_state(NR_FILE_DIRTY)), K(global_page_state(NR_WRITEBACK)), |
b53fc7c29
|
183 |
K(global_page_state(NR_ANON_PAGES)), |
e1759c215
|
184 |
K(global_page_state(NR_FILE_MAPPED)), |
cc7452b6d
|
185 |
K(i.sharedram), |
e1759c215
|
186 187 188 189 |
K(global_page_state(NR_SLAB_RECLAIMABLE) + global_page_state(NR_SLAB_UNRECLAIMABLE)), K(global_page_state(NR_SLAB_RECLAIMABLE)), K(global_page_state(NR_SLAB_UNRECLAIMABLE)), |
c6a7f5728
|
190 |
global_page_state(NR_KERNEL_STACK) * THREAD_SIZE / 1024, |
e1759c215
|
191 192 193 194 195 196 197 |
K(global_page_state(NR_PAGETABLE)), #ifdef CONFIG_QUICKLIST K(quicklist_total_size()), #endif K(global_page_state(NR_UNSTABLE_NFS)), K(global_page_state(NR_BOUNCE)), K(global_page_state(NR_WRITEBACK_TEMP)), |
00619bcc4
|
198 |
K(vm_commit_limit()), |
e1759c215
|
199 200 |
K(committed), (unsigned long)VMALLOC_TOTAL >> 10, |
a5ad88ce8
|
201 202 |
0ul, // used to be vmalloc 'used' 0ul // used to be vmalloc 'largest_chunk' |
6a46079cf
|
203 |
#ifdef CONFIG_MEMORY_FAILURE |
47f8f9297
|
204 |
, atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10) |
6a46079cf
|
205 |
#endif |
79134171d
|
206 |
#ifdef CONFIG_TRANSPARENT_HUGEPAGE |
47f8f9297
|
207 |
, K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) * |
79134171d
|
208 209 |
HPAGE_PMD_NR) #endif |
47f8f9297
|
210 211 212 213 |
#ifdef CONFIG_CMA , K(totalcma_pages) , K(global_page_state(NR_FREE_CMA_PAGES)) #endif |
e1759c215
|
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 |
); hugetlb_report_meminfo(m); arch_report_meminfo(m); return 0; #undef K } static int meminfo_proc_open(struct inode *inode, struct file *file) { return single_open(file, meminfo_proc_show, NULL); } static const struct file_operations meminfo_proc_fops = { .open = meminfo_proc_open, .read = seq_read, .llseek = seq_lseek, .release = single_release, }; static int __init proc_meminfo_init(void) { proc_create("meminfo", 0, NULL, &meminfo_proc_fops); return 0; } |
abaf3787a
|
241 |
fs_initcall(proc_meminfo_init); |