linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] oom: OOM-Killed process don't invoke pagefault-oom
@ 2010-01-14 10:22 KOSAKI Motohiro
  2010-01-14 13:02 ` Nick Piggin
  0 siblings, 1 reply; 5+ messages in thread
From: KOSAKI Motohiro @ 2010-01-14 10:22 UTC (permalink / raw)
  To: Nick Piggin, Jeff Dike, Ingo Molnar, Thomas Gleixner,
	Andrew Morton, LKML, linux-mm
  Cc: kosaki.motohiro


Nick, I've found this issue by code review. I'm glad if you review this
patch.

Thanks.

=============================
commit 1c0fe6e3 (invoke oom-killer from page fault) created
page fault specific oom handler.

But If OOM occur, alloc_pages() in page fault might return
NULL. It mean page fault return VM_FAULT_OOM. But OOM Killer
itself sholdn't invoke next OOM Kill. it is obviously strange.

Plus, process exiting itself makes some free memory. we
don't need kill another process.

Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Nick Piggin <npiggin@suse.de>
Cc: Jeff Dike <jdike@addtoit.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
---
 mm/oom_kill.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 4f167b8..86cecdf 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -596,6 +596,15 @@ void pagefault_out_of_memory(void)
 {
 	unsigned long freed = 0;
 
+	/*
+	 * If the task was received SIGKILL while memory allocation, alloc_pages
+	 * might return NULL and it cause page fault return VM_FAULT_OOM. But
+	 * in such case, the task don't need kill any another task, it need
+	 * just die.
+	 */
+	if (fatal_signal_pending(current))
+		return;
+
 	blocking_notifier_call_chain(&oom_notify_list, 0, &freed);
 	if (freed > 0)
 		/* Got some memory back in the last second. */
-- 
1.6.5.2



--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] oom: OOM-Killed process don't invoke pagefault-oom
  2010-01-14 10:22 [PATCH] oom: OOM-Killed process don't invoke pagefault-oom KOSAKI Motohiro
@ 2010-01-14 13:02 ` Nick Piggin
  2010-01-15  6:21   ` KOSAKI Motohiro
  0 siblings, 1 reply; 5+ messages in thread
From: Nick Piggin @ 2010-01-14 13:02 UTC (permalink / raw)
  To: KOSAKI Motohiro
  Cc: Jeff Dike, Ingo Molnar, Thomas Gleixner, Andrew Morton, LKML, linux-mm

Hi,

I don't think this should be required, because the oom killer does not
kill a new task if there is already one in memdie state.

If you have any further tweaks to the heuristic (such as a fatal signal
pending), then it should probably go in select_bad_process() or
somewhere like that.

Thanks,
Nick

On Thu, Jan 14, 2010 at 07:22:34PM +0900, KOSAKI Motohiro wrote:
> 
> Nick, I've found this issue by code review. I'm glad if you review this
> patch.
> 
> Thanks.
> 
> =============================
> commit 1c0fe6e3 (invoke oom-killer from page fault) created
> page fault specific oom handler.
> 
> But If OOM occur, alloc_pages() in page fault might return
> NULL. It mean page fault return VM_FAULT_OOM. But OOM Killer
> itself sholdn't invoke next OOM Kill. it is obviously strange.
> 
> Plus, process exiting itself makes some free memory. we
> don't need kill another process.
> 
> Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
> Cc: Nick Piggin <npiggin@suse.de>
> Cc: Jeff Dike <jdike@addtoit.com>
> Cc: Ingo Molnar <mingo@elte.hu>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> ---
>  mm/oom_kill.c |    9 +++++++++
>  1 files changed, 9 insertions(+), 0 deletions(-)
> 
> diff --git a/mm/oom_kill.c b/mm/oom_kill.c
> index 4f167b8..86cecdf 100644
> --- a/mm/oom_kill.c
> +++ b/mm/oom_kill.c
> @@ -596,6 +596,15 @@ void pagefault_out_of_memory(void)
>  {
>  	unsigned long freed = 0;
>  
> +	/*
> +	 * If the task was received SIGKILL while memory allocation, alloc_pages
> +	 * might return NULL and it cause page fault return VM_FAULT_OOM. But
> +	 * in such case, the task don't need kill any another task, it need
> +	 * just die.
> +	 */
> +	if (fatal_signal_pending(current))
> +		return;
> +
>  	blocking_notifier_call_chain(&oom_notify_list, 0, &freed);
>  	if (freed > 0)
>  		/* Got some memory back in the last second. */
> -- 
> 1.6.5.2
> 
> 

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] oom: OOM-Killed process don't invoke pagefault-oom
  2010-01-14 13:02 ` Nick Piggin
@ 2010-01-15  6:21   ` KOSAKI Motohiro
  2010-01-18  7:29     ` Nick Piggin
  0 siblings, 1 reply; 5+ messages in thread
From: KOSAKI Motohiro @ 2010-01-15  6:21 UTC (permalink / raw)
  To: Nick Piggin
  Cc: kosaki.motohiro, Jeff Dike, Ingo Molnar, Thomas Gleixner,
	Andrew Morton, LKML, linux-mm

> Hi,
> 
> I don't think this should be required, because the oom killer does not
> kill a new task if there is already one in memdie state.
> 
> If you have any further tweaks to the heuristic (such as a fatal signal
> pending), then it should probably go in select_bad_process() or
> somewhere like that.

I see, I misunderstood. very thanks.



--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] oom: OOM-Killed process don't invoke pagefault-oom
  2010-01-15  6:21   ` KOSAKI Motohiro
@ 2010-01-18  7:29     ` Nick Piggin
  2010-01-18  8:21       ` KOSAKI Motohiro
  0 siblings, 1 reply; 5+ messages in thread
From: Nick Piggin @ 2010-01-18  7:29 UTC (permalink / raw)
  To: KOSAKI Motohiro
  Cc: Jeff Dike, Ingo Molnar, Thomas Gleixner, Andrew Morton, LKML, linux-mm

On Fri, Jan 15, 2010 at 03:21:40PM +0900, KOSAKI Motohiro wrote:
> > Hi,
> > 
> > I don't think this should be required, because the oom killer does not
> > kill a new task if there is already one in memdie state.
> > 
> > If you have any further tweaks to the heuristic (such as a fatal signal
> > pending), then it should probably go in select_bad_process() or
> > somewhere like that.
> 
> I see, I misunderstood. very thanks.

Well, it *might* be a good idea to check for fatal signal pending
similar your patch. Because I think there could be large latency between
the signal and the task moving to exit state if the process is waiting
uninterruptible in the kernel for a while.

But if you do it in select_bad_process() then it would work for all
classes of oom kill.

Thanks,
Nick

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] oom: OOM-Killed process don't invoke pagefault-oom
  2010-01-18  7:29     ` Nick Piggin
@ 2010-01-18  8:21       ` KOSAKI Motohiro
  0 siblings, 0 replies; 5+ messages in thread
From: KOSAKI Motohiro @ 2010-01-18  8:21 UTC (permalink / raw)
  To: Nick Piggin
  Cc: kosaki.motohiro, Jeff Dike, Ingo Molnar, Thomas Gleixner,
	Andrew Morton, LKML, linux-mm

> On Fri, Jan 15, 2010 at 03:21:40PM +0900, KOSAKI Motohiro wrote:
> > > Hi,
> > > 
> > > I don't think this should be required, because the oom killer does not
> > > kill a new task if there is already one in memdie state.
> > > 
> > > If you have any further tweaks to the heuristic (such as a fatal signal
> > > pending), then it should probably go in select_bad_process() or
> > > somewhere like that.
> > 
> > I see, I misunderstood. very thanks.
> 
> Well, it *might* be a good idea to check for fatal signal pending
> similar your patch. Because I think there could be large latency between
> the signal and the task moving to exit state if the process is waiting
> uninterruptible in the kernel for a while.
> 
> But if you do it in select_bad_process() then it would work for all
> classes of oom kill.

Thank you for good advise. I'll make next version so :)



--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-01-18  8:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-14 10:22 [PATCH] oom: OOM-Killed process don't invoke pagefault-oom KOSAKI Motohiro
2010-01-14 13:02 ` Nick Piggin
2010-01-15  6:21   ` KOSAKI Motohiro
2010-01-18  7:29     ` Nick Piggin
2010-01-18  8:21       ` KOSAKI Motohiro

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox