Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mm/swap: fix system stuck due to infinite loop
> In the case of high system memory and load pressure, we ran ltp test > and found that the system was stuck, the direct memory reclaim was > all stuck in io_schedule > For the first time involving the swap part, there is no good way to fix > the problem The solution is protecting the clean file pages. Look at this: > On ChromiumOS, we do not use swap. When memory is low, the only > way to free memory is to reclaim pages from the file list. This > results in a lot of thrashing under low memory conditions. We see > the system become unresponsive for minutes before it eventually OOMs. > We also see very slow browser tab switching under low memory. Instead > of an unresponsive system, we'd really like the kernel to OOM as soon > as it starts to thrash. If it can't keep the working set in memory, > then OOM. Losing one of many tabs is a better behaviour for the user > than an unresponsive system. > This patch create a new sysctl, min_filelist_kbytes, which disables > reclaim of file-backed pages when when there are less than min_filelist_bytes > worth of such pages in the cache. This tunable is handy for low memory > systems using solid-state storage where interactive response is more important > than not OOMing. > With this patch and min_filelist_kbytes set to 50000, I see very little block > layer activity during low memory. The system stays responsive under low > memory and browser tab switching is fast. Eventually, a process a gets killed > by OOM. Without this patch, the system gets wedged for minutes before it > eventually OOMs. — https://lore.kernel.org/patchwork/patch/222042/ This patch can almost completely eliminate thrashing under memory pressure. Effects - Improving system responsiveness under low-memory conditions; - Improving performans in I/O bound tasks under memory pressure; - OOM killer comes faster (with hard protection); - Fast system reclaiming after OOM. Read more: https://github.com/hakavlad/le9-patch The patch: From 371e3e5290652e97d5279d8cd215cd356c1fb47b Mon Sep 17 00:00:00 2001 From: Alexey Avramov <hakavlad@inbox.lv> Date: Mon, 5 Apr 2021 01:53:26 +0900 Subject: [PATCH] mm/vmscan: add sysctl knobs for protecting the specified amount of clean file cache The kernel does not have a mechanism for targeted protection of clean file pages (CFP). A certain amount of the CFP is required by the userspace for normal operation. First of all, you need a cache of shared libraries and executable files. If the volume of the CFP cache falls below a certain level, thrashing and even livelock occurs. Protection of CFP may be used to prevent thrashing and reducing I/O under memory pressure. Hard protection of CFP may be used to avoid high latency and prevent livelock in near-OOM conditions. The patch provides sysctl knobs for protecting the specified amount of clean file cache under memory pressure. The vm.clean_low_kbytes sysctl knob provides *best-effort* protection of CFP. The CFP on the current node won't be reclaimed uder memory pressure when their volume is below vm.clean_low_kbytes *unless* we threaten to OOM or have no swap space or vm.swappiness=0. Setting it to a high value may result in a early eviction of anonymous pages into the swap space by attempting to hold the protected amount of clean file pages in memory. The default value is defined by CONFIG_CLEAN_LOW_KBYTES (suggested 0 in Kconfig). The vm.clean_min_kbytes sysctl knob provides *hard* protection of CFP. The CFP on the current node won't be reclaimed under memory pressure when their volume is below vm.clean_min_kbytes. Setting it to a high value may result in a early out-of-memory condition due to the inability to reclaim the protected amount of CFP when other types of pages cannot be reclaimed. The default value is defined by CONFIG_CLEAN_MIN_KBYTES (suggested 0 in Kconfig). Reported-by: Artem S. Tashkinov <aros@gmx.com> Signed-off-by: Alexey Avramov <hakavlad@inbox.lv>
- Loading branch information