Files
KanonifyX Tzy 0377300b4a mm: Patch le9ec
Protect the working set under memory pressure to prevent thrashing, avoid high latency and prevent livelock in near-OOM conditions

The kernel does not provide a way to protect the working set under memory pressure. A certain amount of anonymous and clean file pages is required by the userspace for normal operation. First of all, the userspace needs a cache of shared libraries and executable binaries. If the amount of the clean file pages falls below a certain level, then thrashing and even livelock can take place.

The patch provides sysctl knobs for protecting the working set (anonymous and clean file pages) under memory pressure.

The vm.anon_min_kbytes sysctl knob provides hard protection of anonymous pages. The anonymous pages on the current node won't be reclaimed under any conditions when their amount is below vm.anon_min_kbytes. This knob may be used to prevent excessive swap thrashing when anonymous memory is low (for example, when memory is going to be overfilled by compressed data of zram module).

The vm.clean_low_kbytes sysctl knob provides best-effort protection of clean file pages. The file pages on the current node won't be reclaimed under memory pressure when the amount of clean file pages is below vm.clean_low_kbytes unless we threaten to OOM. Protection of clean file pages using this knob may be used when swapping is still possible to

- Prevent disk I/O thrashing under memory pressure.
- Improve performance in disk cache-bound tasks under memory pressure.

The vm.clean_min_kbytes sysctl knob provides hard protection of clean file pages. The file pages on the current node won't be reclaimed under memory pressure when the amount of clean file pages is below vm.clean_min_kbytes. Hard protection of clean file pages using this knob may be used to

- Prevent disk I/O thrashing under memory pressure even with no free swap space.
- Improve performance in disk cache-bound tasks under memory pressure.
- Avoid high latency and prevent livelock in near-OOM conditions.

le9ec patches provide three sysctl knobs (vm.anon_min_kbytes, vm.clean_low_kbytes, vm.clean_min_kbytes) with zero values and does not protect the working set by default (CONFIG_ANON_MIN_KBYTES=0, CONFIG_CLEAN_LOW_KBYTES=0, CONFIG_CLEAN_MIN_KBYTES=0). You can specify other values during kernel build, or change the knob values on the fly.

Effects
- Improving system responsiveness under low-memory conditions.
- Improving performance in I/O bound tasks under memory pressure;
- OOM killer comes faster (with hard protection).
- Fast system reclaiming after OOM (with hard protection).

Note that the effects depend on the values of the sysctl tunables.

source patch: https://github.com/hakavlad/le9-patch

Signed-off-by: kanonifyX <kanonify01@gmail.com>
2025-08-31 09:51:17 +07:00
..
2017-10-13 11:27:08 +00:00
2021-06-03 08:23:27 +02:00
2025-08-31 09:51:17 +07:00
2021-06-03 08:23:27 +02:00
2017-05-11 13:26:42 -07:00
2021-06-03 08:40:14 +02:00
2019-03-22 14:10:44 -07:00