Commit 84ad5802 authored by Johannes Weiner's avatar Johannes Weiner Committed by Linus Torvalds

proc: meminfo: estimate available memory more conservatively

The MemAvailable item in /proc/meminfo is to give users a hint of how
much memory is allocatable without causing swapping, so it excludes the
zones' low watermarks as unavailable to userspace.

However, for a userspace allocation, kswapd will actually reclaim until
the free pages hit a combination of the high watermark and the page
allocator's lowmem protection that keeps a certain amount of DMA and
DMA32 memory from userspace as well.

Subtract the full amount we know to be unavailable to userspace from the
number of free pages when calculating MemAvailable.
Signed-off-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: Mel Gorman <mgorman@suse.de>
Acked-by: default avatarMichal Hocko <mhocko@suse.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent a8d01437
...@@ -57,11 +57,8 @@ static int meminfo_proc_show(struct seq_file *m, void *v) ...@@ -57,11 +57,8 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
/* /*
* Estimate the amount of memory available for userspace allocations, * Estimate the amount of memory available for userspace allocations,
* without causing swapping. * without causing swapping.
*
* Free memory cannot be taken below the low watermark, before the
* system starts swapping.
*/ */
available = i.freeram - wmark_low; available = i.freeram - totalreserve_pages;
/* /*
* Not all the page cache can be freed, otherwise the system will * Not all the page cache can be freed, otherwise the system will
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment