From: Kirill Korotaev Date: Mon, 14 Nov 2005 00:06:41 +0000 (-0800) Subject: [PATCH] mm: __GFP_NOFAIL fix X-Git-Tag: v2.6.15-rc2~193 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=885036d32f5d3c427c3e2b385b5a5503805e3e52;p=linux-2.6 [PATCH] mm: __GFP_NOFAIL fix In __alloc_pages(): if ((p->flags & (PF_MEMALLOC | PF_MEMDIE)) && !in_interrupt()) { /* go through the zonelist yet again, ignoring mins */ for (i = 0; zones[i] != NULL; i++) { struct zone *z = zones[i]; page = buffered_rmqueue(z, order, gfp_mask); if (page) { zone_statistics(zonelist, z); goto got_pg; } } goto nopage; <<<< HERE!!! FAIL... } kswapd (which has PF_MEMALLOC flag) can fail to allocate memory even when it allocates it with __GFP_NOFAIL flag. Signed-Off-By: Pavel Emelianov Signed-Off-By: Denis Lunev Signed-Off-By: Kirill Korotaev Cc: Nick Piggin Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 987225bdd6..b37dc0f78d 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -895,6 +895,7 @@ zone_reclaim_retry: if (((p->flags & PF_MEMALLOC) || unlikely(test_thread_flag(TIF_MEMDIE))) && !in_interrupt()) { if (!(gfp_mask & __GFP_NOMEMALLOC)) { +nofail_alloc: /* go through the zonelist yet again, ignoring mins */ for (i = 0; (z = zones[i]) != NULL; i++) { if (!cpuset_zone_allowed(z, gfp_mask)) @@ -903,6 +904,10 @@ zone_reclaim_retry: if (page) goto got_pg; } + if (gfp_mask & __GFP_NOFAIL) { + blk_congestion_wait(WRITE, HZ/50); + goto nofail_alloc; + } } goto nopage; }