From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx133.postini.com [74.125.245.133]) by kanga.kvack.org (Postfix) with SMTP id 856D46B003D for ; Thu, 6 Jun 2013 00:55:38 -0400 (EDT) Received: by mail-qa0-f48.google.com with SMTP id cm16so55333qab.0 for ; Wed, 05 Jun 2013 21:55:37 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <1370488193-4747-1-git-send-email-hannes@cmpxchg.org> References: <1370488193-4747-1-git-send-email-hannes@cmpxchg.org> From: =?UTF-8?B?5YiY6IOc6Juf?= Date: Thu, 6 Jun 2013 12:55:17 +0800 Message-ID: Subject: Re: [patch 1/2] arch: invoke oom-killer from page fault Content-Type: multipart/alternative; boundary=90e6ba10af85137c2204de7520e2 Sender: owner-linux-mm@kvack.org List-ID: To: Johannes Weiner Cc: Andrew Morton , Michal Hocko , David Rientjes , KAMEZAWA Hiroyuki , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org --90e6ba10af85137c2204de7520e2 Content-Type: text/plain; charset=ISO-8859-1 www.all-sky.com 2013/6/6 Johannes Weiner > Since '1c0fe6e mm: invoke oom-killer from page fault', page fault > handlers should not directly kill faulting tasks in an out of memory > condition. Instead, they should be invoking the OOM killer to pick > the right task. Convert the remaining architectures. > > Signed-off-by: Johannes Weiner > --- > arch/arc/mm/fault.c | 6 ++++-- > arch/metag/mm/fault.c | 6 ++++-- > arch/mn10300/mm/fault.c | 7 ++++--- > arch/openrisc/mm/fault.c | 8 ++++---- > arch/score/mm/fault.c | 8 ++++---- > arch/tile/mm/fault.c | 8 ++++---- > 6 files changed, 24 insertions(+), 19 deletions(-) > > diff --git a/arch/arc/mm/fault.c b/arch/arc/mm/fault.c > index c0decc1..d5ec60a 100644 > --- a/arch/arc/mm/fault.c > +++ b/arch/arc/mm/fault.c > @@ -207,8 +207,10 @@ out_of_memory: > } > up_read(&mm->mmap_sem); > > - if (user_mode(regs)) > - do_group_exit(SIGKILL); /* This will never return */ > + if (user_mode(regs)) { > + pagefault_out_of_memory(); > + return; > + } > > goto no_context; > > diff --git a/arch/metag/mm/fault.c b/arch/metag/mm/fault.c > index 2c75bf7..8fddf46 100644 > --- a/arch/metag/mm/fault.c > +++ b/arch/metag/mm/fault.c > @@ -224,8 +224,10 @@ do_sigbus: > */ > out_of_memory: > up_read(&mm->mmap_sem); > - if (user_mode(regs)) > - do_group_exit(SIGKILL); > + if (user_mode(regs)) { > + pagefault_out_of_memory(); > + return 1; > + } > > no_context: > /* Are we prepared to handle this kernel fault? */ > diff --git a/arch/mn10300/mm/fault.c b/arch/mn10300/mm/fault.c > index d48a84f..8a2e6de 100644 > --- a/arch/mn10300/mm/fault.c > +++ b/arch/mn10300/mm/fault.c > @@ -345,9 +345,10 @@ no_context: > */ > out_of_memory: > up_read(&mm->mmap_sem); > - printk(KERN_ALERT "VM: killing process %s\n", tsk->comm); > - if ((fault_code & MMUFCR_xFC_ACCESS) == MMUFCR_xFC_ACCESS_USR) > - do_exit(SIGKILL); > + if ((fault_code & MMUFCR_xFC_ACCESS) == MMUFCR_xFC_ACCESS_USR) { > + pagefault_out_of_memory(); > + return; > + } > goto no_context; > > do_sigbus: > diff --git a/arch/openrisc/mm/fault.c b/arch/openrisc/mm/fault.c > index e2bfafc..4a41f84 100644 > --- a/arch/openrisc/mm/fault.c > +++ b/arch/openrisc/mm/fault.c > @@ -267,10 +267,10 @@ out_of_memory: > __asm__ __volatile__("l.nop 1"); > > up_read(&mm->mmap_sem); > - printk("VM: killing process %s\n", tsk->comm); > - if (user_mode(regs)) > - do_exit(SIGKILL); > - goto no_context; > + if (!user_mode(regs)) > + goto no_context; > + pagefault_out_of_memory(); > + return; > > do_sigbus: > up_read(&mm->mmap_sem); > diff --git a/arch/score/mm/fault.c b/arch/score/mm/fault.c > index 47b600e..6b18fb0 100644 > --- a/arch/score/mm/fault.c > +++ b/arch/score/mm/fault.c > @@ -172,10 +172,10 @@ out_of_memory: > down_read(&mm->mmap_sem); > goto survive; > } > - printk("VM: killing process %s\n", tsk->comm); > - if (user_mode(regs)) > - do_group_exit(SIGKILL); > - goto no_context; > + if (!user_mode(regs)) > + goto no_context; > + pagefault_out_of_memory(); > + return; > > do_sigbus: > up_read(&mm->mmap_sem); > diff --git a/arch/tile/mm/fault.c b/arch/tile/mm/fault.c > index 3d2b81c..f7f99f9 100644 > --- a/arch/tile/mm/fault.c > +++ b/arch/tile/mm/fault.c > @@ -573,10 +573,10 @@ out_of_memory: > down_read(&mm->mmap_sem); > goto survive; > } > - pr_alert("VM: killing process %s\n", tsk->comm); > - if (!is_kernel_mode) > - do_group_exit(SIGKILL); > - goto no_context; > + if (is_kernel_mode) > + goto no_context; > + pagefault_out_of_memory(); > + return 0; > > do_sigbus: > up_read(&mm->mmap_sem); > -- > 1.8.2.3 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > Please read the FAQ at http://www.tux.org/lkml/ > --90e6ba10af85137c2204de7520e2 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable


2013/6/= 6 Johannes Weiner <hannes@cmpxchg.org>
Since '1c0fe6e mm: invoke oom-killer fro= m page fault', page fault
handlers should not directly kill faulting tasks in an out of memory
condition. =A0Instead, they should be invoking the OOM killer to pick
the right task. =A0Convert the remaining architectures.

Signed-off-by: Johannes Weiner <ha= nnes@cmpxchg.org>
---
=A0arch/arc/mm/fault.c =A0 =A0 =A0| 6 ++++--
=A0arch/metag/mm/fault.c =A0 =A0| 6 ++++--
=A0arch/mn10300/mm/fault.c =A0| 7 ++++---
=A0arch/openrisc/mm/fault.c | 8 ++++----
=A0arch/score/mm/fault.c =A0 =A0| 8 ++++----
=A0arch/tile/mm/fault.c =A0 =A0 | 8 ++++----
=A06 files changed, 24 insertions(+), 19 deletions(-)

diff --git a/arch/arc/mm/fault.c b/arch/arc/mm/fault.c
index c0decc1..d5ec60a 100644
--- a/arch/arc/mm/fault.c
+++ b/arch/arc/mm/fault.c
@@ -207,8 +207,10 @@ out_of_memory:
=A0 =A0 =A0 =A0 }
=A0 =A0 =A0 =A0 up_read(&mm->mmap_sem);

- =A0 =A0 =A0 if (user_mode(regs))
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 do_group_exit(SIGKILL); /* This will never re= turn */
+ =A0 =A0 =A0 if (user_mode(regs)) {
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 pagefault_out_of_memory();
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 return;
+ =A0 =A0 =A0 }

=A0 =A0 =A0 =A0 goto no_context;

diff --git a/arch/metag/mm/fault.c b/arch/metag/mm/fault.c
index 2c75bf7..8fddf46 100644
--- a/arch/metag/mm/fault.c
+++ b/arch/metag/mm/fault.c
@@ -224,8 +224,10 @@ do_sigbus:
=A0 =A0 =A0 =A0 =A0*/
=A0out_of_memory:
=A0 =A0 =A0 =A0 up_read(&mm->mmap_sem);
- =A0 =A0 =A0 if (user_mode(regs))
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 do_group_exit(SIGKILL);
+ =A0 =A0 =A0 if (user_mode(regs)) {
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 pagefault_out_of_memory();
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 return 1;
+ =A0 =A0 =A0 }

=A0no_context:
=A0 =A0 =A0 =A0 /* Are we prepared to handle this kernel fault? =A0*/
diff --git a/arch/mn10300/mm/fault.c b/arch/mn10300/mm/fault.c
index d48a84f..8a2e6de 100644
--- a/arch/mn10300/mm/fault.c
+++ b/arch/mn10300/mm/fault.c
@@ -345,9 +345,10 @@ no_context:
=A0 */
=A0out_of_memory:
=A0 =A0 =A0 =A0 up_read(&mm->mmap_sem);
- =A0 =A0 =A0 printk(KERN_ALERT "VM: killing process %s\n", tsk-&= gt;comm);
- =A0 =A0 =A0 if ((fault_code & MMUFCR_xFC_ACCESS) =3D=3D MMUFCR_xFC_AC= CESS_USR)
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 do_exit(SIGKILL);
+ =A0 =A0 =A0 if ((fault_code & MMUFCR_xFC_ACCESS) =3D=3D MMUFCR_xFC_AC= CESS_USR) {
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 pagefault_out_of_memory();
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 return;
+ =A0 =A0 =A0 }
=A0 =A0 =A0 =A0 goto no_context;

=A0do_sigbus:
diff --git a/arch/openrisc/mm/fault.c b/arch/openrisc/mm/fault.c
index e2bfafc..4a41f84 100644
--- a/arch/openrisc/mm/fault.c
+++ b/arch/openrisc/mm/fault.c
@@ -267,10 +267,10 @@ out_of_memory:
=A0 =A0 =A0 =A0 __asm__ __volatile__("l.nop 1");

=A0 =A0 =A0 =A0 up_read(&mm->mmap_sem);
- =A0 =A0 =A0 printk("VM: killing process %s\n", tsk->comm); - =A0 =A0 =A0 if (user_mode(regs))
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 do_exit(SIGKILL);
- =A0 =A0 =A0 goto no_context;
+ =A0 =A0 =A0 if (!user_mode(regs))
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 goto no_context;
+ =A0 =A0 =A0 pagefault_out_of_memory();
+ =A0 =A0 =A0 return;

=A0do_sigbus:
=A0 =A0 =A0 =A0 up_read(&mm->mmap_sem);
diff --git a/arch/score/mm/fault.c b/arch/score/mm/fault.c
index 47b600e..6b18fb0 100644
--- a/arch/score/mm/fault.c
+++ b/arch/score/mm/fault.c
@@ -172,10 +172,10 @@ out_of_memory:
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 down_read(&mm->mmap_sem);
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 goto survive;
=A0 =A0 =A0 =A0 }
- =A0 =A0 =A0 printk("VM: killing process %s\n", tsk->comm); - =A0 =A0 =A0 if (user_mode(regs))
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 do_group_exit(SIGKILL);
- =A0 =A0 =A0 goto no_context;
+ =A0 =A0 =A0 if (!user_mode(regs))
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 goto no_context;
+ =A0 =A0 =A0 pagefault_out_of_memory();
+ =A0 =A0 =A0 return;

=A0do_sigbus:
=A0 =A0 =A0 =A0 up_read(&mm->mmap_sem);
diff --git a/arch/tile/mm/fault.c b/arch/tile/mm/fault.c
index 3d2b81c..f7f99f9 100644
--- a/arch/tile/mm/fault.c
+++ b/arch/tile/mm/fault.c
@@ -573,10 +573,10 @@ out_of_memory:
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 down_read(&mm->mmap_sem);
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 goto survive;
=A0 =A0 =A0 =A0 }
- =A0 =A0 =A0 pr_alert("VM: killing process %s\n", tsk->comm);=
- =A0 =A0 =A0 if (!is_kernel_mode)
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 do_group_exit(SIGKILL);
- =A0 =A0 =A0 goto no_context;
+ =A0 =A0 =A0 if (is_kernel_mode)
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 goto no_context;
+ =A0 =A0 =A0 pagefault_out_of_memory();
+ =A0 =A0 =A0 return 0;

=A0do_sigbus:
=A0 =A0 =A0 =A0 up_read(&mm->mmap_sem);
--
1.8.2.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel= " in
the body of a message to major= domo@vger.kernel.org
More majordomo info at =A0http://vger.kernel.org/majordomo-info.html
Please read the FAQ at =A0http://www.tux.org/lkml/

--90e6ba10af85137c2204de7520e2-- -- 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: email@kvack.org