Skip to content

Commit ade63b4

Browse files
yangyang20220519akpm00
authored andcommitted
mm/page_alloc: make the annotations of available memory more accurate
Not all systems use swap, so estimating available memory would help to prevent swapping or OOM of system that not use swap. And we need to reserve some page cache to prevent swapping or thrashing. If somebody is accessing the pages in pagecache, and if too much would be freed, most accesses might mean reading data from disk, i.e. thrashing. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Yang Yang <[email protected]> Signed-off-by: CGEL ZTE <[email protected]> Cc: Matthew Wilcox <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent dc89997 commit ade63b4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

mm/page_alloc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5800,14 +5800,14 @@ long si_mem_available(void)
58005800

58015801
/*
58025802
* Estimate the amount of memory available for userspace allocations,
5803-
* without causing swapping.
5803+
* without causing swapping or OOM.
58045804
*/
58055805
available = global_zone_page_state(NR_FREE_PAGES) - totalreserve_pages;
58065806

58075807
/*
58085808
* Not all the page cache can be freed, otherwise the system will
5809-
* start swapping. Assume at least half of the page cache, or the
5810-
* low watermark worth of cache, needs to stay.
5809+
* start swapping or thrashing. Assume at least half of the page
5810+
* cache, or the low watermark worth of cache, needs to stay.
58115811
*/
58125812
pagecache = pages[LRU_ACTIVE_FILE] + pages[LRU_INACTIVE_FILE];
58135813
pagecache -= min(pagecache / 2, wmark_low);

0 commit comments

Comments
 (0)