From: Kirill Korotaev Date: Thu, 7 Dec 2006 04:32:27 +0000 (-0800) Subject: [PATCH] OOM can panic due to processes stuck in __alloc_pages() X-Git-Tag: v2.6.20-rc1~145^2^2~334 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=b43a57bb4dae72e8f7232e7c821a8799eda30022;p=karo-tx-linux.git [PATCH] OOM can panic due to processes stuck in __alloc_pages() OOM can panic due to the processes stuck in __alloc_pages() doing infinite rebalance loop while no memory can be reclaimed. OOM killer tries to kill some processes, but unfortunetaly, rebalance label was moved by someone below the TIF_MEMDIE check, so buddy allocator doesn't see that process is OOM-killed and it can simply fail the allocation :/ Observed in reality on RHEL4(2.6.9)+OpenVZ kernel when a user doing some memory allocation tricks triggered OOM panic. 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 cd47e8f7bd5b..a840e702722c 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1180,6 +1180,7 @@ restart: /* This allocation should allow future memory freeing. */ +rebalance: if (((p->flags & PF_MEMALLOC) || unlikely(test_thread_flag(TIF_MEMDIE))) && !in_interrupt()) { if (!(gfp_mask & __GFP_NOMEMALLOC)) { @@ -1201,7 +1202,6 @@ nofail_alloc: if (!wait) goto nopage; -rebalance: cond_resched(); /* We now go into synchronous reclaim */