From ac80551df4aa65c46123da65bd9f9676cb0b2079 Mon Sep 17 00:00:00 2001 From: Vinayak Menon Date: Wed, 20 Feb 2019 12:21:49 +0530 Subject: [PATCH] mm: reduce the time spend by killed tasks in alloc path There are issues reported where the tasks killed by LMK holding huge amounts of memory, loops for seconds in the reclaim path, thus causing OOMs to happen from other contexts or a panic when oom path finds that there are no killable tasks. This patch brings back a change in older kernel versions to avoid reclaim when a fatal signal is pending. This is more improtant in our case unlike upstream, as we loop almost forever in reclaim path when there are LMK killable tasks (see lmk_kill_possible). Another change done by the patch is to return without sleep in too_many_isolated case for tasks with fatal signal pending. Change-Id: Icd2bb7a9602ea6566425f7918e34c218bbed21cb Signed-off-by: Vinayak Menon --- mm/page_alloc.c | 3 +++ mm/vmscan.c | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 3b4784fe46e3..c2df6a75a1eb 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -4683,6 +4683,9 @@ retry: if (current->flags & PF_MEMALLOC) goto nopage; + if (fatal_signal_pending(current) && !(gfp_mask & __GFP_NOFAIL)) + goto nopage; + /* Try direct reclaim and then allocating */ page = __alloc_pages_direct_reclaim(gfp_mask, order, alloc_flags, ac, &did_some_progress); diff --git a/mm/vmscan.c b/mm/vmscan.c index 3a75418ee092..d81fc723be0c 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2026,13 +2026,13 @@ shrink_inactive_list(unsigned long nr_to_scan, struct lruvec *lruvec, if (stalled) return 0; - /* wait a bit for the reclaimer. */ - msleep(100); - stalled = true; - /* We are about to die and free our memory. Return now. */ if (fatal_signal_pending(current)) return SWAP_CLUSTER_MAX; + + /* wait a bit for the reclaimer. */ + msleep(100); + stalled = true; } lru_add_drain();