diff mbox

[11/14] powerpc: invoke oom-killer from page fault

Message ID 20100422161224.465958039@suse.de (mailing list archive)
State Accepted, archived
Delegated to: Benjamin Herrenschmidt
Headers show

Commit Message

Nick Piggin April 22, 2010, 4:06 p.m. UTC
As explained in commit 1c0fe6e3bd, we want to call the architecture independent
oom killer when getting an unexplained OOM from handle_mm_fault, rather than
simply killing current.

Cc: linuxppc-dev@ozlabs.org
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: linux-arch@vger.kernel.org
Signed-off-by: Nick Piggin <npiggin@suse.de>
---

Comments

David Rientjes April 22, 2010, 9:44 p.m. UTC | #1
On Fri, 23 Apr 2010, npiggin@suse.de wrote:

> As explained in commit 1c0fe6e3bd, we want to call the architecture independent
> oom killer when getting an unexplained OOM from handle_mm_fault, rather than
> simply killing current.
> 
> Cc: linuxppc-dev@ozlabs.org
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: linux-arch@vger.kernel.org
> Signed-off-by: Nick Piggin <npiggin@suse.de>
> ---
> Index: linux-2.6/arch/powerpc/mm/fault.c
> ===================================================================
> --- linux-2.6.orig/arch/powerpc/mm/fault.c
> +++ linux-2.6/arch/powerpc/mm/fault.c
> @@ -359,15 +359,10 @@ bad_area_nosemaphore:
>   */
>  out_of_memory:
>  	up_read(&mm->mmap_sem);
> -	if (is_global_init(current)) {
> -		yield();
> -		down_read(&mm->mmap_sem);
> -		goto survive;
> -	}
> -	printk("VM: killing process %s\n", current->comm);
> -	if (user_mode(regs))
> -		do_group_exit(SIGKILL);
> -	return SIGKILL;
> +	if (!user_mode(regs))
> +		return SIGKILL;
> +	pagefault_out_of_memory();
> +	return 0;

Do we really want to return 0 and indicate that the fault was handled?  It 
seems more consistent to do

	if (user_mode(regs))
		pagefault_out_of_memory();
	return SIGKILL;
Nick Piggin April 23, 2010, 10:27 a.m. UTC | #2
On Thu, Apr 22, 2010 at 02:44:22PM -0700, David Rientjes wrote:
> On Fri, 23 Apr 2010, npiggin@suse.de wrote:
> 
> > As explained in commit 1c0fe6e3bd, we want to call the architecture independent
> > oom killer when getting an unexplained OOM from handle_mm_fault, rather than
> > simply killing current.
> > 
> > Cc: linuxppc-dev@ozlabs.org
> > Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> > Cc: linux-arch@vger.kernel.org
> > Signed-off-by: Nick Piggin <npiggin@suse.de>
> > ---
> > Index: linux-2.6/arch/powerpc/mm/fault.c
> > ===================================================================
> > --- linux-2.6.orig/arch/powerpc/mm/fault.c
> > +++ linux-2.6/arch/powerpc/mm/fault.c
> > @@ -359,15 +359,10 @@ bad_area_nosemaphore:
> >   */
> >  out_of_memory:
> >  	up_read(&mm->mmap_sem);
> > -	if (is_global_init(current)) {
> > -		yield();
> > -		down_read(&mm->mmap_sem);
> > -		goto survive;
> > -	}
> > -	printk("VM: killing process %s\n", current->comm);
> > -	if (user_mode(regs))
> > -		do_group_exit(SIGKILL);
> > -	return SIGKILL;
> > +	if (!user_mode(regs))
> > +		return SIGKILL;
> > +	pagefault_out_of_memory();
> > +	return 0;
> 
> Do we really want to return 0 and indicate that the fault was handled?  It 
> seems more consistent to do
> 
> 	if (user_mode(regs))
> 		pagefault_out_of_memory();
> 	return SIGKILL;

Well we don't necessarily want to kill current.
pagefault_out_of_memory() could elect to send a SIGKILL if wants to, but
if it decides current should not be terminated, then we have to just
retry the page fault.
diff mbox

Patch

Index: linux-2.6/arch/powerpc/mm/fault.c
===================================================================
--- linux-2.6.orig/arch/powerpc/mm/fault.c
+++ linux-2.6/arch/powerpc/mm/fault.c
@@ -359,15 +359,10 @@  bad_area_nosemaphore:
  */
 out_of_memory:
 	up_read(&mm->mmap_sem);
-	if (is_global_init(current)) {
-		yield();
-		down_read(&mm->mmap_sem);
-		goto survive;
-	}
-	printk("VM: killing process %s\n", current->comm);
-	if (user_mode(regs))
-		do_group_exit(SIGKILL);
-	return SIGKILL;
+	if (!user_mode(regs))
+		return SIGKILL;
+	pagefault_out_of_memory();
+	return 0;
 
 do_sigbus:
 	up_read(&mm->mmap_sem);