From dcca2bde4f86a14d3291660bede8f1844fe2b3df Mon Sep 17 00:00:00 2001 From: Will Schmidt <will_schmidt@vnet.ibm.com> Date: Tue, 16 Oct 2007 01:24:18 -0700 Subject: [PATCH] During VM oom condition, kill all threads in process group We have had complaints where a threaded application is left in a bad state after one of it's threads is killed when we hit a VM: out_of_memory condition. Killing just one of the process threads can leave the application in a bad state, whereas killing the entire process group would allow for the application to restart, or be otherwise handled, and makes it very obvious that something has gone wrong. This change allows the entire process group to be taken down, rather than just the one thread. Signed-off-by: Will Schmidt <will_schmidt@vnet.ibm.com> Cc: Richard Henderson <rth@twiddle.net> Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru> Cc: Russell King <rmk@arm.linux.org.uk> Cc: Ian Molton <spyro@f2s.com> Cc: Haavard Skinnemoen <hskinnemoen@atmel.com> Cc: Mikael Starvik <starvik@axis.com> Cc: David Howells <dhowells@redhat.com> Cc: Andi Kleen <ak@suse.de> Cc: "Luck, Tony" <tony.luck@intel.com> Cc: Hirokazu Takata <takata@linux-m32r.org> Cc: Geert Uytterhoeven <geert@linux-m68k.org> Cc: Roman Zippel <zippel@linux-m68k.org> Cc: Ralf Baechle <ralf@linux-mips.org> Cc: Kyle McMartin <kyle@mcmartin.ca> Cc: Matthew Wilcox <willy@debian.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Heiko Carstens <heiko.carstens@de.ibm.com> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com> Cc: Paul Mundt <lethal@linux-sh.org> Cc: Kazumoto Kojima <kkojima@rr.iij4u.or.jp> Cc: Richard Curnow <rc@rc0.org.uk> Cc: William Lee Irwin III <wli@holomorphy.com> Cc: "David S. Miller" <davem@davemloft.net> Cc: Chris Zankel <chris@zankel.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> --- arch/alpha/mm/fault.c | 2 +- arch/arm/mm/fault.c | 2 +- arch/avr32/mm/fault.c | 2 +- arch/cris/mm/fault.c | 2 +- arch/frv/mm/fault.c | 2 +- arch/ia64/mm/fault.c | 2 +- arch/m32r/mm/fault.c | 2 +- arch/m68k/mm/fault.c | 2 +- arch/mips/mm/fault.c | 2 +- arch/parisc/mm/fault.c | 2 +- arch/ppc/mm/fault.c | 2 +- arch/s390/mm/fault.c | 2 +- arch/sh/mm/fault.c | 2 +- arch/sh64/mm/fault.c | 2 +- arch/sparc/mm/fault.c | 2 +- arch/sparc64/mm/fault.c | 2 +- arch/x86/mm/fault_32.c | 2 +- arch/xtensa/mm/fault.c | 2 +- 18 files changed, 18 insertions(+), 18 deletions(-) diff --git a/arch/alpha/mm/fault.c b/arch/alpha/mm/fault.c index a0e18da594d94..25154df3055ab 100644 --- a/arch/alpha/mm/fault.c +++ b/arch/alpha/mm/fault.c @@ -197,7 +197,7 @@ do_page_fault(unsigned long address, unsigned long mmcsr, current->comm, current->pid); if (!user_mode(regs)) goto no_context; - do_exit(SIGKILL); + do_group_exit(SIGKILL); do_sigbus: /* Send a sigbus, regardless of whether we were in kernel diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c index 846cce48e2b7f..59ed1d05b71bf 100644 --- a/arch/arm/mm/fault.c +++ b/arch/arm/mm/fault.c @@ -266,7 +266,7 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs) * the page fault gracefully. */ printk("VM: killing process %s\n", tsk->comm); - do_exit(SIGKILL); + do_group_exit(SIGKILL); return 0; } if (fault & VM_FAULT_SIGBUS) { diff --git a/arch/avr32/mm/fault.c b/arch/avr32/mm/fault.c index ae2d2c593b2b0..11472f8701bdf 100644 --- a/arch/avr32/mm/fault.c +++ b/arch/avr32/mm/fault.c @@ -216,7 +216,7 @@ asmlinkage void do_page_fault(unsigned long ecr, struct pt_regs *regs) } printk("VM: Killing process %s\n", tsk->comm); if (user_mode(regs)) - do_exit(SIGKILL); + do_group_exit(SIGKILL); goto no_context; do_sigbus: diff --git a/arch/cris/mm/fault.c b/arch/cris/mm/fault.c index 8672ab7d7978f..8aab814306955 100644 --- a/arch/cris/mm/fault.c +++ b/arch/cris/mm/fault.c @@ -360,7 +360,7 @@ do_page_fault(unsigned long address, struct pt_regs *regs, up_read(&mm->mmap_sem); printk("VM: killing process %s\n", tsk->comm); if (user_mode(regs)) - do_exit(SIGKILL); + do_group_exit(SIGKILL); goto no_context; do_sigbus: diff --git a/arch/frv/mm/fault.c b/arch/frv/mm/fault.c index 6798fa0257b15..05093d41d98ea 100644 --- a/arch/frv/mm/fault.c +++ b/arch/frv/mm/fault.c @@ -259,7 +259,7 @@ asmlinkage void do_page_fault(int datammu, unsigned long esr0, unsigned long ear up_read(&mm->mmap_sem); printk("VM: killing process %s\n", current->comm); if (user_mode(__frame)) - do_exit(SIGKILL); + do_group_exit(SIGKILL); goto no_context; do_sigbus: diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c index 9150ffaff9e89..32f26253c4e8c 100644 --- a/arch/ia64/mm/fault.c +++ b/arch/ia64/mm/fault.c @@ -281,6 +281,6 @@ ia64_do_page_fault (unsigned long address, unsigned long isr, struct pt_regs *re } printk(KERN_CRIT "VM: killing process %s\n", current->comm); if (user_mode(regs)) - do_exit(SIGKILL); + do_group_exit(SIGKILL); goto no_context; } diff --git a/arch/m32r/mm/fault.c b/arch/m32r/mm/fault.c index 676a1c443d28c..70a766aad3e0b 100644 --- a/arch/m32r/mm/fault.c +++ b/arch/m32r/mm/fault.c @@ -278,7 +278,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long error_code, } printk("VM: killing process %s\n", tsk->comm); if (error_code & ACE_USERMODE) - do_exit(SIGKILL); + do_group_exit(SIGKILL); goto no_context; do_sigbus: diff --git a/arch/m68k/mm/fault.c b/arch/m68k/mm/fault.c index 578b48f47b9e3..eaa6186811595 100644 --- a/arch/m68k/mm/fault.c +++ b/arch/m68k/mm/fault.c @@ -188,7 +188,7 @@ int do_page_fault(struct pt_regs *regs, unsigned long address, printk("VM: killing process %s\n", current->comm); if (user_mode(regs)) - do_exit(SIGKILL); + do_group_exit(SIGKILL); no_context: current->thread.signo = SIGBUS; diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c index 521771b373ded..5699c7713e2f0 100644 --- a/arch/mips/mm/fault.c +++ b/arch/mips/mm/fault.c @@ -180,7 +180,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long write, } printk("VM: killing process %s\n", tsk->comm); if (user_mode(regs)) - do_exit(SIGKILL); + do_group_exit(SIGKILL); goto no_context; do_sigbus: diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c index 7899ab87785aa..1c091b415cd9b 100644 --- a/arch/parisc/mm/fault.c +++ b/arch/parisc/mm/fault.c @@ -263,6 +263,6 @@ void do_page_fault(struct pt_regs *regs, unsigned long code, up_read(&mm->mmap_sem); printk(KERN_CRIT "VM: killing process %s\n", current->comm); if (user_mode(regs)) - do_exit(SIGKILL); + do_group_exit(SIGKILL); goto no_context; } diff --git a/arch/ppc/mm/fault.c b/arch/ppc/mm/fault.c index b98244e277fbc..94913ddcf76e8 100644 --- a/arch/ppc/mm/fault.c +++ b/arch/ppc/mm/fault.c @@ -297,7 +297,7 @@ int do_page_fault(struct pt_regs *regs, unsigned long address, } printk("VM: killing process %s\n", current->comm); if (user_mode(regs)) - do_exit(SIGKILL); + do_group_exit(SIGKILL); return SIGKILL; do_sigbus: diff --git a/arch/s390/mm/fault.c b/arch/s390/mm/fault.c index 4c1ac341ec806..14c241ccdd4d9 100644 --- a/arch/s390/mm/fault.c +++ b/arch/s390/mm/fault.c @@ -218,7 +218,7 @@ static int do_out_of_memory(struct pt_regs *regs, unsigned long error_code, } printk("VM: killing process %s\n", tsk->comm); if (regs->psw.mask & PSW_MASK_PSTATE) - do_exit(SIGKILL); + do_group_exit(SIGKILL); do_no_context(regs, error_code, address); return 0; } diff --git a/arch/sh/mm/fault.c b/arch/sh/mm/fault.c index 04a39aa7f1f97..4729668ce5bf3 100644 --- a/arch/sh/mm/fault.c +++ b/arch/sh/mm/fault.c @@ -214,7 +214,7 @@ asmlinkage void __kprobes do_page_fault(struct pt_regs *regs, } printk("VM: killing process %s\n", tsk->comm); if (user_mode(regs)) - do_exit(SIGKILL); + do_group_exit(SIGKILL); goto no_context; do_sigbus: diff --git a/arch/sh64/mm/fault.c b/arch/sh64/mm/fault.c index 0d069d82141f2..dd81c669c79b5 100644 --- a/arch/sh64/mm/fault.c +++ b/arch/sh64/mm/fault.c @@ -334,7 +334,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long writeaccess, } printk("VM: killing process %s\n", tsk->comm); if (user_mode(regs)) - do_exit(SIGKILL); + do_group_exit(SIGKILL); goto no_context; do_sigbus: diff --git a/arch/sparc/mm/fault.c b/arch/sparc/mm/fault.c index 50747fe443568..e4d9c8e19df5d 100644 --- a/arch/sparc/mm/fault.c +++ b/arch/sparc/mm/fault.c @@ -369,7 +369,7 @@ asmlinkage void do_sparc_fault(struct pt_regs *regs, int text_fault, int write, up_read(&mm->mmap_sem); printk("VM: killing process %s\n", tsk->comm); if (from_user) - do_exit(SIGKILL); + do_group_exit(SIGKILL); goto no_context; do_sigbus: diff --git a/arch/sparc64/mm/fault.c b/arch/sparc64/mm/fault.c index 9f7740eee8d29..e2027f27c0fe7 100644 --- a/arch/sparc64/mm/fault.c +++ b/arch/sparc64/mm/fault.c @@ -463,7 +463,7 @@ asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs) up_read(&mm->mmap_sem); printk("VM: killing process %s\n", current->comm); if (!(regs->tstate & TSTATE_PRIV)) - do_exit(SIGKILL); + do_group_exit(SIGKILL); goto handle_kernel_fault; intr_or_no_mm: diff --git a/arch/x86/mm/fault_32.c b/arch/x86/mm/fault_32.c index be72c2a5b03b4..c686ae20fd6bb 100644 --- a/arch/x86/mm/fault_32.c +++ b/arch/x86/mm/fault_32.c @@ -593,7 +593,7 @@ fastcall void __kprobes do_page_fault(struct pt_regs *regs, } printk("VM: killing process %s\n", tsk->comm); if (error_code & 4) - do_exit(SIGKILL); + do_group_exit(SIGKILL); goto no_context; do_sigbus: diff --git a/arch/xtensa/mm/fault.c b/arch/xtensa/mm/fault.c index 45d28f217c030..2f842859948f5 100644 --- a/arch/xtensa/mm/fault.c +++ b/arch/xtensa/mm/fault.c @@ -152,7 +152,7 @@ void do_page_fault(struct pt_regs *regs) } printk("VM: killing process %s\n", current->comm); if (user_mode(regs)) - do_exit(SIGKILL); + do_group_exit(SIGKILL); bad_page_fault(regs, address, SIGKILL); return; -- GitLab