Re: [PATCH] oom killer: break from infinite loop

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: David Rientjes
Date: Tuesday, April 6, 2010 - 3:40 pm

On Mon, 5 Apr 2010, Mel Gorman wrote:


Ok, that's reasonable.  We already handle this case indirectly in -mm.

oom-give-current-access-to-memory-reserves-if-it-has-been-killed.patch in 
-mm makes the oom killer set TIF_MEMDIE for current and return without 
killing any other task; it's unnecesary to check if 
!test_thread_flag(TIF_MEMDIE) before that since the oom killer will be a 
no-op anyway if there exist TIF_MEMDIE threads.

The problem is that the should_alloc_retry() logic isn't checked when the 
oom killer is called, we immediately retry instead even if the oom killer 
didn't do anything.  So if the oom killed task fails to exit because it's 
looping in the page allocator, that's going to happen forever since 
reclaim has failed and the oom killer can't kill anything else (or it's 
__GFP_NOFAIL and __alloc_pages_may_oom() will infinitely loop without ever 
returning).

I guess this could potentially deplete memory reserves if too many threads 
have fatal signals and the oom killer is constantly invoked, regardless of 
__GFP_NOFAIL or not.  That's why we have always opted to kill a memory 
hogging task instead via a tasklist scan: we want to set TIF_MEMDIE for as 
few tasks as possible with a large upside of memory freeing.

I'm wondering if we should check should_alloc_retry() first, it seems like 
we could get rid of a few different branches in the oom killer path by 
doing so: the comparisons to PAGE_ALLOC_COSTLY_ORDER, __GFP_NORETRY, etc.


Yeah, that's what 
oom-give-current-access-to-memory-reserves-if-it-has-been-killed.patch 
effectively does.


Pagefault ooms default to killing current first in -mm and only kill 
another task if current is unkillable for the architectures that use 
pagefault_out_of_memory(); the rest of the architectures such as powerpc 
just kill current.  So while this scenario is plausible, I don't think 
there would be a large number of processes getting killed: 
pagefault_out_of_memory() will kill current and give it access to memory 
reserves and the oom killer won't perform any needless oom killing while 
that is happening.
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] oom killer: break from infinite loop, Anfei Zhou, (Wed Mar 24, 9:25 am)
Re: [PATCH] oom killer: break from infinite loop, KOSAKI Motohiro, (Wed Mar 24, 7:51 pm)
Re: [PATCH] oom killer: break from infinite loop, Andrew Morton, (Fri Mar 26, 3:08 pm)
Re: [PATCH] oom killer: break from infinite loop, Oleg Nesterov, (Fri Mar 26, 3:33 pm)
Re: [PATCH] oom killer: break from infinite loop, David Rientjes, (Sat Mar 27, 7:46 pm)
Re: [PATCH] oom killer: break from infinite loop, Oleg Nesterov, (Sun Mar 28, 9:28 am)
Re: [PATCH] oom killer: break from infinite loop, David Rientjes, (Sun Mar 28, 2:21 pm)
Re: [PATCH] oom killer: break from infinite loop, Oleg Nesterov, (Mon Mar 29, 4:21 am)
Re: [PATCH] oom killer: break from infinite loop, Oleg Nesterov, (Mon Mar 29, 4:46 am)
Re: [PATCH] oom killer: break from infinite loop, David Rientjes, (Mon Mar 29, 1:01 pm)
Re: [PATCH] oom killer: break from infinite loop, David Rientjes, (Tue Mar 30, 1:29 pm)
Re: [PATCH] oom killer: break from infinite loop, KAMEZAWA Hiroyuki, (Tue Mar 30, 5:57 pm)
Re: [PATCH] oom killer: break from infinite loop, David Rientjes, (Tue Mar 30, 11:07 pm)
Re: [PATCH] oom killer: break from infinite loop, KAMEZAWA Hiroyuki, (Tue Mar 30, 11:13 pm)
Re: [PATCH] oom killer: break from infinite loop, Balbir Singh, (Tue Mar 30, 11:30 pm)
Re: [PATCH] oom killer: break from infinite loop, KAMEZAWA Hiroyuki, (Tue Mar 30, 11:31 pm)
Re: [PATCH] oom killer: break from infinite loop, David Rientjes, (Tue Mar 30, 11:32 pm)
Re: [PATCH] oom killer: break from infinite loop, David Rientjes, (Wed Mar 31, 12:04 am)
Re: [PATCH] oom killer: break from infinite loop, Mel Gorman, (Fri Apr 2, 3:17 am)
[PATCH -mm 0/4] oom: linux has threads, Oleg Nesterov, (Fri Apr 2, 11:30 am)
Re: [PATCH] oom killer: break from infinite loop, David Rientjes, (Sun Apr 4, 4:26 pm)
Re: [PATCH] oom killer: break from infinite loop, Mel Gorman, (Mon Apr 5, 3:47 am)
Re: [PATCH] oom killer: break from infinite loop, David Rientjes, (Tue Apr 6, 3:40 pm)