Commit b43a57bb authored by Kirill Korotaev's avatar Kirill Korotaev Committed by Linus Torvalds

[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: default avatarDenis Lunev <den@sw.ru>
Signed-off-by: default avatarKirill Korotaev <dev@openvz.org>
Cc: Nick Piggin <nickpiggin@yahoo.com.au>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent a3eea484
...@@ -1180,6 +1180,7 @@ __alloc_pages(gfp_t gfp_mask, unsigned int order, ...@@ -1180,6 +1180,7 @@ __alloc_pages(gfp_t gfp_mask, unsigned int order,
/* This allocation should allow future memory freeing. */ /* This allocation should allow future memory freeing. */
rebalance:
if (((p->flags & PF_MEMALLOC) || unlikely(test_thread_flag(TIF_MEMDIE))) if (((p->flags & PF_MEMALLOC) || unlikely(test_thread_flag(TIF_MEMDIE)))
&& !in_interrupt()) { && !in_interrupt()) {
if (!(gfp_mask & __GFP_NOMEMALLOC)) { if (!(gfp_mask & __GFP_NOMEMALLOC)) {
...@@ -1201,7 +1202,6 @@ __alloc_pages(gfp_t gfp_mask, unsigned int order, ...@@ -1201,7 +1202,6 @@ __alloc_pages(gfp_t gfp_mask, unsigned int order,
if (!wait) if (!wait)
goto nopage; goto nopage;
rebalance:
cond_resched(); cond_resched();
/* We now go into synchronous reclaim */ /* We now go into synchronous reclaim */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment