diff options
Diffstat (limited to 'fs/proc/meminfo.c')
-rw-r--r-- | fs/proc/meminfo.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c index a77d2b299199..24270eceddbf 100644 --- a/fs/proc/meminfo.c +++ b/fs/proc/meminfo.c | |||
@@ -26,7 +26,11 @@ static int meminfo_proc_show(struct seq_file *m, void *v) | |||
26 | unsigned long committed; | 26 | unsigned long committed; |
27 | struct vmalloc_info vmi; | 27 | struct vmalloc_info vmi; |
28 | long cached; | 28 | long cached; |
29 | long available; | ||
30 | unsigned long pagecache; | ||
31 | unsigned long wmark_low = 0; | ||
29 | unsigned long pages[NR_LRU_LISTS]; | 32 | unsigned long pages[NR_LRU_LISTS]; |
33 | struct zone *zone; | ||
30 | int lru; | 34 | int lru; |
31 | 35 | ||
32 | /* | 36 | /* |
@@ -47,12 +51,44 @@ static int meminfo_proc_show(struct seq_file *m, void *v) | |||
47 | for (lru = LRU_BASE; lru < NR_LRU_LISTS; lru++) | 51 | for (lru = LRU_BASE; lru < NR_LRU_LISTS; lru++) |
48 | pages[lru] = global_page_state(NR_LRU_BASE + lru); | 52 | pages[lru] = global_page_state(NR_LRU_BASE + lru); |
49 | 53 | ||
54 | for_each_zone(zone) | ||
55 | wmark_low += zone->watermark[WMARK_LOW]; | ||
56 | |||
57 | /* | ||
58 | * Estimate the amount of memory available for userspace allocations, | ||
59 | * without causing swapping. | ||
60 | * | ||
61 | * Free memory cannot be taken below the low watermark, before the | ||
62 | * system starts swapping. | ||
63 | */ | ||
64 | available = i.freeram - wmark_low; | ||
65 | |||
66 | /* | ||
67 | * Not all the page cache can be freed, otherwise the system will | ||
68 | * start swapping. Assume at least half of the page cache, or the | ||
69 | * low watermark worth of cache, needs to stay. | ||
70 | */ | ||
71 | pagecache = pages[LRU_ACTIVE_FILE] + pages[LRU_INACTIVE_FILE]; | ||
72 | pagecache -= min(pagecache / 2, wmark_low); | ||
73 | available += pagecache; | ||
74 | |||
75 | /* | ||
76 | * Part of the reclaimable swap consists of items that are in use, | ||
77 | * and cannot be freed. Cap this estimate at the low watermark. | ||
78 | */ | ||
79 | available += global_page_state(NR_SLAB_RECLAIMABLE) - | ||
80 | min(global_page_state(NR_SLAB_RECLAIMABLE) / 2, wmark_low); | ||
81 | |||
82 | if (available < 0) | ||
83 | available = 0; | ||
84 | |||
50 | /* | 85 | /* |
51 | * Tagged format, for easy grepping and expansion. | 86 | * Tagged format, for easy grepping and expansion. |
52 | */ | 87 | */ |
53 | seq_printf(m, | 88 | seq_printf(m, |
54 | "MemTotal: %8lu kB\n" | 89 | "MemTotal: %8lu kB\n" |
55 | "MemFree: %8lu kB\n" | 90 | "MemFree: %8lu kB\n" |
91 | "MemAvailable: %8lu kB\n" | ||
56 | "Buffers: %8lu kB\n" | 92 | "Buffers: %8lu kB\n" |
57 | "Cached: %8lu kB\n" | 93 | "Cached: %8lu kB\n" |
58 | "SwapCached: %8lu kB\n" | 94 | "SwapCached: %8lu kB\n" |
@@ -105,6 +141,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v) | |||
105 | , | 141 | , |
106 | K(i.totalram), | 142 | K(i.totalram), |
107 | K(i.freeram), | 143 | K(i.freeram), |
144 | K(available), | ||
108 | K(i.bufferram), | 145 | K(i.bufferram), |
109 | K(cached), | 146 | K(cached), |
110 | K(total_swapcache_pages()), | 147 | K(total_swapcache_pages()), |