aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Weiner <hannes@cmpxchg.org>2013-07-08 18:59:50 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-07-09 13:33:20 -0400
commit609838cfed972d49a65aac7923a9ff5cbe482e30 (patch)
treeb9043963715a04c84b4030ccd3951a32129a6ed8
parent54f72fe022d9b2c4de40043a118881121190a117 (diff)
mm: invoke oom-killer from remaining unconverted page fault handlers
A few remaining architectures directly kill the page faulting task in an out of memory situation. This is usually not a good idea since that task might not even use a significant amount of memory and so may not be the optimal victim to resolve the situation. Since 2.6.29's 1c0fe6e ("mm: invoke oom-killer from page fault") there is a hook that architecture page fault handlers are supposed to call to invoke the OOM killer and let it pick the right task to kill. Convert the remaining architectures over to this hook. To have the previous behavior of simply taking out the faulting task the vm.oom_kill_allocating_task sysctl can be set to 1. Signed-off-by: Johannes Weiner <hannes@cmpxchg.org> Reviewed-by: Michal Hocko <mhocko@suse.cz> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Acked-by: David Rientjes <rientjes@google.com> Acked-by: Vineet Gupta <vgupta@synopsys.com> [arch/arc bits] Cc: James Hogan <james.hogan@imgtec.com> Cc: David Howells <dhowells@redhat.com> Cc: Jonas Bonn <jonas@southpole.se> Cc: Chen Liqin <liqin.chen@sunplusct.com> Cc: Lennox Wu <lennox.wu@gmail.com> Cc: Chris Metcalf <cmetcalf@tilera.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--arch/arc/mm/fault.c6
-rw-r--r--arch/metag/mm/fault.c6
-rw-r--r--arch/mn10300/mm/fault.c7
-rw-r--r--arch/openrisc/mm/fault.c8
-rw-r--r--arch/score/mm/fault.c8
-rw-r--r--arch/tile/mm/fault.c8
6 files changed, 24 insertions, 19 deletions
diff --git a/arch/arc/mm/fault.c b/arch/arc/mm/fault.c
index 318164cabdfc..0fd1f0d515ff 100644
--- a/arch/arc/mm/fault.c
+++ b/arch/arc/mm/fault.c
@@ -207,8 +207,10 @@ out_of_memory:
207 } 207 }
208 up_read(&mm->mmap_sem); 208 up_read(&mm->mmap_sem);
209 209
210 if (user_mode(regs)) 210 if (user_mode(regs)) {
211 do_group_exit(SIGKILL); /* This will never return */ 211 pagefault_out_of_memory();
212 return;
213 }
212 214
213 goto no_context; 215 goto no_context;
214 216
diff --git a/arch/metag/mm/fault.c b/arch/metag/mm/fault.c
index 2c75bf7357c5..8fddf46e6c62 100644
--- a/arch/metag/mm/fault.c
+++ b/arch/metag/mm/fault.c
@@ -224,8 +224,10 @@ do_sigbus:
224 */ 224 */
225out_of_memory: 225out_of_memory:
226 up_read(&mm->mmap_sem); 226 up_read(&mm->mmap_sem);
227 if (user_mode(regs)) 227 if (user_mode(regs)) {
228 do_group_exit(SIGKILL); 228 pagefault_out_of_memory();
229 return 1;
230 }
229 231
230no_context: 232no_context:
231 /* Are we prepared to handle this kernel fault? */ 233 /* Are we prepared to handle this kernel fault? */
diff --git a/arch/mn10300/mm/fault.c b/arch/mn10300/mm/fault.c
index d48a84fd7fae..8a2e6ded9a44 100644
--- a/arch/mn10300/mm/fault.c
+++ b/arch/mn10300/mm/fault.c
@@ -345,9 +345,10 @@ no_context:
345 */ 345 */
346out_of_memory: 346out_of_memory:
347 up_read(&mm->mmap_sem); 347 up_read(&mm->mmap_sem);
348 printk(KERN_ALERT "VM: killing process %s\n", tsk->comm); 348 if ((fault_code & MMUFCR_xFC_ACCESS) == MMUFCR_xFC_ACCESS_USR) {
349 if ((fault_code & MMUFCR_xFC_ACCESS) == MMUFCR_xFC_ACCESS_USR) 349 pagefault_out_of_memory();
350 do_exit(SIGKILL); 350 return;
351 }
351 goto no_context; 352 goto no_context;
352 353
353do_sigbus: 354do_sigbus:
diff --git a/arch/openrisc/mm/fault.c b/arch/openrisc/mm/fault.c
index e2bfafce66c5..4a41f8493ab0 100644
--- a/arch/openrisc/mm/fault.c
+++ b/arch/openrisc/mm/fault.c
@@ -267,10 +267,10 @@ out_of_memory:
267 __asm__ __volatile__("l.nop 1"); 267 __asm__ __volatile__("l.nop 1");
268 268
269 up_read(&mm->mmap_sem); 269 up_read(&mm->mmap_sem);
270 printk("VM: killing process %s\n", tsk->comm); 270 if (!user_mode(regs))
271 if (user_mode(regs)) 271 goto no_context;
272 do_exit(SIGKILL); 272 pagefault_out_of_memory();
273 goto no_context; 273 return;
274 274
275do_sigbus: 275do_sigbus:
276 up_read(&mm->mmap_sem); 276 up_read(&mm->mmap_sem);
diff --git a/arch/score/mm/fault.c b/arch/score/mm/fault.c
index 47b600e4b2c5..6b18fb0189ae 100644
--- a/arch/score/mm/fault.c
+++ b/arch/score/mm/fault.c
@@ -172,10 +172,10 @@ out_of_memory:
172 down_read(&mm->mmap_sem); 172 down_read(&mm->mmap_sem);
173 goto survive; 173 goto survive;
174 } 174 }
175 printk("VM: killing process %s\n", tsk->comm); 175 if (!user_mode(regs))
176 if (user_mode(regs)) 176 goto no_context;
177 do_group_exit(SIGKILL); 177 pagefault_out_of_memory();
178 goto no_context; 178 return;
179 179
180do_sigbus: 180do_sigbus:
181 up_read(&mm->mmap_sem); 181 up_read(&mm->mmap_sem);
diff --git a/arch/tile/mm/fault.c b/arch/tile/mm/fault.c
index 3d2b81c163a6..f7f99f90cbe0 100644
--- a/arch/tile/mm/fault.c
+++ b/arch/tile/mm/fault.c
@@ -573,10 +573,10 @@ out_of_memory:
573 down_read(&mm->mmap_sem); 573 down_read(&mm->mmap_sem);
574 goto survive; 574 goto survive;
575 } 575 }
576 pr_alert("VM: killing process %s\n", tsk->comm); 576 if (is_kernel_mode)
577 if (!is_kernel_mode) 577 goto no_context;
578 do_group_exit(SIGKILL); 578 pagefault_out_of_memory();
579 goto no_context; 579 return 0;
580 580
581do_sigbus: 581do_sigbus:
582 up_read(&mm->mmap_sem); 582 up_read(&mm->mmap_sem);