diff --git a/mm/page_alloc.c b/mm/page_alloc.c index ae28c22a7fdb66ec85539a9693c72cda8ade221d..2dbb2fc68837e5fa0cf5db4d497370cd37a8d5e9 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1794,6 +1794,10 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order, if (p->flags & PF_MEMALLOC) goto nopage; + /* Avoid allocations with no watermarks from looping endlessly */ + if (test_thread_flag(TIF_MEMDIE) && !(gfp_mask & __GFP_NOFAIL)) + goto nopage; + /* Try direct reclaim and then allocating */ page = __alloc_pages_direct_reclaim(gfp_mask, order, zonelist, high_zoneidx,