Skip to contentSkip to conversation

: OOM can panic due to processes stuck in __alloc_pages()

PATCH In review Kirill Korotaev 2 participants 2 messages Nov 13, 2006

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 : 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.

mm/page_alloc.c renamed from mm/page_alloc.c.oomx +1 -1
@@ -1251,6 +1251,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)) {
@@ -1272,7 +1273,6 @@ nofail_alloc:
 	if (!wait)
 		goto nopage;
 
-rebalance:
 	cond_resched();
 
 	/* We now go into synchronous reclaim */
#1 lore raw
Quoted 24 lines · On Mon, 13 Nov 2006 22:13:47 +0300 Kirill Korotaev <[email protected]> wrote:

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.

mm/page_alloc.c renamed from mm/page_alloc.c.oomx +1 -0
@@ -1251,6 +1251,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)) {

mm/page_alloc.c nofail_alloc: · line 1278

Quoted 7 lines
mm/page_alloc.c renamed from mm/page_alloc.c.oomx +0 -1
@@ -1272,7 +1273,6 @@ nofail_alloc:
 	if (!wait)
 		goto nopage;
 
-rebalance:
 	cond_resched();
 
 	/* We now go into synchronous reclaim */

Your patch reverts a change made by Nick's a457c255ae59b5f7f52f63fc88d5e530101772c6 two years ago.

It looks right to me, but the original change was unchangelogged and I wonder what it was aiming to do?