swappiness
This control is used to define how aggressive the kernel will swap
memory pages. Higher values will increase aggressiveness, lower values
decrease the amount of swap. A value of 0 instructs the kernel not to
initiate swap until the amount of free and file-backed pages is less
than the high water mark in a zone.— linux-5.0/Documentation/sysctl/vm.txt
MemAvailable
An estimate of how much memory is available for starting new
applications, without swapping. Calculated from MemFree,
SReclaimable, the size of the file LRU lists, and the low
watermarks in each zone.
The estimate takes into account that the system needs some
page cache to function well, and that not all reclaimable
slab will be reclaimable, due to items being in use. The
impact of those factors will vary from system to system.— linux-5.0/Documentation/filesystems/proc.txt (file
/proc/meminfo
).
What are the current values of the low and high watermarks on my system? And what value are they relative to, e.g. if I want to express them as a percentage?
Best Answer
The watermarks are the
low
andhigh
values in/proc/zoneinfo
, shown in units of pages (4096 bytes on x86).On my 8GB system, most of the pages are split between the DMA32 zone and the Normal zone. (And everything belongs to Node 0, because it is not a NUMA system).
The watermarks are a proportion of
managed
.Very broadly speaking, the watermarks on my system are somewhere between 1% and 3%.
See __setup_per_zone_wmarks(). (Also free_area_init_core(), set_dma_reserve(), and the commit mm: introduce new field "managed_pages" to struct zone.)
The kernel may dynamically increase the watermarks (boost_watermark()) if it appears necessary.
The behaviour is tunable by
watermark_boost_factor
andwatermark_scale_factor
in Documentation/sysctl/vm.txt. The scale factor defaults to 0.1%, and the boost factor defaults to 150% of the scale factor.On my system the watermarks are dominated by
min
. The per-zonemin
watermark is set proportionally frommin_free_kbytes
. The kernel had calculated a defaultmin_free_kbytes
value of 67584. Related: an explanation of how this value ofmin_free_kbytes
was calculated.I do not know why the minimum watermark for the "Normal" zone appeared as 31449 pages = 125796 KiB! This appears to contradict the source code. So far, I can only think it was a bug or a hardware fault. See this question: My low and high watermarks seem higher than predicted by Documentation/sysctl/vm.txt