diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 0ebffb0bb98b..7e3c79e79e5b 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -4853,8 +4853,19 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order, } /* Caller is not willing to reclaim, we can't balance anything */ - if (!can_direct_reclaim) + if (!can_direct_reclaim) { + /* + * Reclaim/compaction cannot run, so defrag_mode's strategy + * of enforcing ALLOC_NOFRAGMENT cannot be fulfilled. Allow + * fallbacks rather than failing the allocation outright. + */ + if (defrag_mode && (alloc_flags & ALLOC_NOFRAGMENT) && + (gfp_mask & __GFP_KSWAPD_RECLAIM)) { + alloc_flags &= ~ALLOC_NOFRAGMENT; + goto retry; + } goto nopage; + } /* Avoid recursion of direct reclaim */ if (current->flags & PF_MEMALLOC)