When memory is only a little and there are some pagecache can be reclaimed to avoid triggering OOM, but these pagecache is just right what the program is currently reading. The pagecache will be reclaimed and read from disk again, which will keeping a long time before OOM. Due to read-ahead, there are large of redundant read of disk which aggravate this problem.
These two patch lessen the problem by early break read-ahead.
Liu Shixin (2): mm/readahead: stop readahead loop if memcg charge fails mm/readahead: limit sync readahead while too many active refault
include/linux/fs.h | 1 + include/linux/pagemap.h | 1 + mm/filemap.c | 16 ++++++++++++++++ mm/readahead.c | 21 ++++++++++++++++----- 4 files changed, 34 insertions(+), 5 deletions(-)