Reserve memory for the page cache to resolve page cache thrashing caused by a large number of anonymous page allocations

Updated at:

When anonymous page allocations consume all available memory, the kernel continuously evicts page cache entries to make room — a feedback loop known as page cache thrashing. This degrades file I/O performance and can trigger Out of Memory (OOM) kills that terminate running processes. The vm.min_cache_kbytes parameter on Alibaba Cloud Linux 3 sets a lower bound on page cache memory, preventing anonymous pages from crowding out the cache entirely.

Limits

  • Operating system: Alibaba Cloud Linux 3

  • Basic support (manual configuration required): kernel version ≥ 5.10.112-11

  • Adaptive default support (auto-configured): kernel version ≥ 5.10.134-18

How it works

vm.min_cache_kbytes sets a floor on the amount of memory reserved for the page cache. During memory reclamation, the kernel will not reclaim page cache memory below this threshold, so anonymous pages cannot consume it.

The parameter was introduced in two stages:

  • Kernel 5.10.112-11: introduced vm.min_cache_kbytes with an initial value of 0 (no reservation). Manual configuration is required.

  • Kernel 5.10.134-18 and later: the kernel automatically sets a default based on the instance's total physical memory. Manual configuration is only needed for non-default tuning.

Default values (kernel ≥ 5.10.134-18)

Total memoryDefault vm.min_cache_kbytes
(0, 4 GB]150 MB
(4 GB, 8 GB]300 MB
(8 GB, 16 GB]400 MB
(16 GB, 128 GB]500 MB
> 128 GB1024 MB (1 GB)
Important

These defaults cover most workloads and are sufficient for stable system operation. If your kernel version is between 5.10.112-11 and 5.10.134-18, the parameter exists but defaults are not applied automatically — the initial value is 0, so configure it manually.

When to tune

Adjust vm.min_cache_kbytes if your system shows either of these symptoms:

  • OOM kills occur frequently under the current configuration

  • File I/O performance shows jitter caused by excessive page cache reclamation

Warning

Setting this value too high reduces available memory for user-space applications (anonymous page space), which can cause premature OOM events and terminate normal application processes. Setting it too low (or 0) may not prevent page cache thrashing, leading to system instability under high load. Always adjust based on your specific workload, memory monitoring data, and kernel version.

Set vm.min_cache_kbytes

Replace <KB> with the amount of memory to reserve, in kilobytes. For example, to reserve 1 GB, use 1048576. To disable the reservation, use 0.

Method 1: /proc interface

sudo sh -c 'echo <KB> > /proc/sys/vm/min_cache_kbytes'

Method 2: sysctl

sudo sysctl -w vm.min_cache_kbytes=<KB>