diff options
-rw-r--r-- | Documentation/filesystems/proc.txt | 9 | ||||
-rw-r--r-- | fs/proc/meminfo.c | 37 |
2 files changed, 46 insertions, 0 deletions
diff --git a/Documentation/filesystems/proc.txt b/Documentation/filesystems/proc.txt index 22d89aa37218..8533f5f9bb2d 100644 --- a/Documentation/filesystems/proc.txt +++ b/Documentation/filesystems/proc.txt | |||
@@ -767,6 +767,7 @@ The "Locked" indicates whether the mapping is locked in memory or not. | |||
767 | 767 | ||
768 | MemTotal: 16344972 kB | 768 | MemTotal: 16344972 kB |
769 | MemFree: 13634064 kB | 769 | MemFree: 13634064 kB |
770 | MemAvailable: 14836172 kB | ||
770 | Buffers: 3656 kB | 771 | Buffers: 3656 kB |
771 | Cached: 1195708 kB | 772 | Cached: 1195708 kB |
772 | SwapCached: 0 kB | 773 | SwapCached: 0 kB |
@@ -799,6 +800,14 @@ AnonHugePages: 49152 kB | |||
799 | MemTotal: Total usable ram (i.e. physical ram minus a few reserved | 800 | MemTotal: Total usable ram (i.e. physical ram minus a few reserved |
800 | bits and the kernel binary code) | 801 | bits and the kernel binary code) |
801 | MemFree: The sum of LowFree+HighFree | 802 | MemFree: The sum of LowFree+HighFree |
803 | MemAvailable: An estimate of how much memory is available for starting new | ||
804 | applications, without swapping. Calculated from MemFree, | ||
805 | SReclaimable, the size of the file LRU lists, and the low | ||
806 | watermarks in each zone. | ||
807 | The estimate takes into account that the system needs some | ||
808 | page cache to function well, and that not all reclaimable | ||
809 | slab will be reclaimable, due to items being in use. The | ||
810 | impact of those factors will vary from system to system. | ||
802 | Buffers: Relatively temporary storage for raw disk blocks | 811 | Buffers: Relatively temporary storage for raw disk blocks |
803 | shouldn't get tremendously large (20MB or so) | 812 | shouldn't get tremendously large (20MB or so) |
804 | Cached: in-memory cache for files read from the disk (the | 813 | Cached: in-memory cache for files read from the disk (the |
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()), |