summaryrefslogtreecommitdiff
path: root/mm
diff options
context:
space:
mode:
authorTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>2017-11-30 12:12:21 +1100
committerStephen Rothwell <sfr@canb.auug.org.au>2017-11-30 15:44:48 +1100
commit93b39114a49d92203eb7dc3127212f96c425a0e8 (patch)
tree3209b026ed43505681d8619b6072df64187dbd55 /mm
parent8ae8841e429b00f024a9b3af2c2e48c5704aa51e (diff)
mm,oom: use ALLOC_OOM for OOM victim's last second allocation
Manish Jaggi noticed that running LTP oom01/oom02 ltp tests with high core count causes random kernel panics when an OOM victim which consumed memory in a way the OOM reaper does not help was selected by the OOM killer [1]. Since commit 696453e66630ad45 ("mm, oom: task_will_free_mem should skip oom_reaped tasks") changed task_will_free_mem(current) in out_of_memory() to return false as soon as MMF_OOM_SKIP is set, many threads sharing the victim's mm were not able to try allocation from memory reserves after the OOM reaper gave up reclaiming memory. Therefore, this patch allows OOM victims to use ALLOC_OOM watermark for last second allocation attempt. [1] http://lkml.kernel.org/r/e6c83a26-1d59-4afd-55cf-04e58bdde188@caviumnetworks.com Link: http://lkml.kernel.org/r/1511607169-5084-2-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp Fixes: 696453e66630ad45 ("mm, oom: task_will_free_mem should skip oom_reaped tasks") Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Reported-by: Manish Jaggi <mjaggi@caviumnetworks.com> Acked-by: Michal Hocko <mhocko@suse.com> Cc: Michal Hocko <mhocko@suse.com> Cc: Oleg Nesterov <oleg@redhat.com> Cc: Vladimir Davydov <vdavydov.dev@gmail.com> Cc: David Rientjes <rientjes@google.com> Cc: Andrea Arcangeli <aarcange@redhat.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Diffstat (limited to 'mm')
-rw-r--r--mm/page_alloc.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 15e681203257..b2746a7213c6 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -4154,13 +4154,19 @@ struct page *alloc_pages_before_oomkill(const struct oom_control *oc)
* we're still under heavy pressure. But make sure that this reclaim
* attempt shall not depend on __GFP_DIRECT_RECLAIM && !__GFP_NORETRY
* allocation which will never fail due to oom_lock already held.
+ * Also, make sure that OOM victims can try ALLOC_OOM watermark
+ * in case they haven't tried ALLOC_OOM watermark.
*/
int alloc_flags = ALLOC_CPUSET | ALLOC_WMARK_HIGH;
gfp_t gfp_mask = oc->gfp_mask | __GFP_HARDWALL;
+ int reserve_flags;
if (!oc->ac)
return NULL;
gfp_mask &= ~__GFP_DIRECT_RECLAIM;
+ reserve_flags = __gfp_pfmemalloc_flags(gfp_mask);
+ if (reserve_flags)
+ alloc_flags = reserve_flags;
return get_page_from_freelist(gfp_mask, oc->order, alloc_flags, oc->ac);
}