Skip to content

Commit 609838c

Browse files
hnaztorvalds
authored andcommitted
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 <[email protected]> Reviewed-by: Michal Hocko <[email protected]> Cc: KAMEZAWA Hiroyuki <[email protected]> Acked-by: David Rientjes <[email protected]> Acked-by: Vineet Gupta <[email protected]> [arch/arc bits] Cc: James Hogan <[email protected]> Cc: David Howells <[email protected]> Cc: Jonas Bonn <[email protected]> Cc: Chen Liqin <[email protected]> Cc: Lennox Wu <[email protected]> Cc: Chris Metcalf <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 54f72fe commit 609838c

File tree

6 files changed

+24
-19
lines changed

6 files changed

+24
-19
lines changed

arch/arc/mm/fault.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,10 @@ void do_page_fault(struct pt_regs *regs, unsigned long address)
207207
}
208208
up_read(&mm->mmap_sem);
209209

210-
if (user_mode(regs))
211-
do_group_exit(SIGKILL); /* This will never return */
210+
if (user_mode(regs)) {
211+
pagefault_out_of_memory();
212+
return;
213+
}
212214

213215
goto no_context;
214216

arch/metag/mm/fault.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,10 @@ int do_page_fault(struct pt_regs *regs, unsigned long address,
224224
*/
225225
out_of_memory:
226226
up_read(&mm->mmap_sem);
227-
if (user_mode(regs))
228-
do_group_exit(SIGKILL);
227+
if (user_mode(regs)) {
228+
pagefault_out_of_memory();
229+
return 1;
230+
}
229231

230232
no_context:
231233
/* Are we prepared to handle this kernel fault? */

arch/mn10300/mm/fault.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -345,9 +345,10 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long fault_code,
345345
*/
346346
out_of_memory:
347347
up_read(&mm->mmap_sem);
348-
printk(KERN_ALERT "VM: killing process %s\n", tsk->comm);
349-
if ((fault_code & MMUFCR_xFC_ACCESS) == MMUFCR_xFC_ACCESS_USR)
350-
do_exit(SIGKILL);
348+
if ((fault_code & MMUFCR_xFC_ACCESS) == MMUFCR_xFC_ACCESS_USR) {
349+
pagefault_out_of_memory();
350+
return;
351+
}
351352
goto no_context;
352353

353354
do_sigbus:

arch/openrisc/mm/fault.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,10 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long address,
267267
__asm__ __volatile__("l.nop 1");
268268

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

275275
do_sigbus:
276276
up_read(&mm->mmap_sem);

arch/score/mm/fault.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,10 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long write,
172172
down_read(&mm->mmap_sem);
173173
goto survive;
174174
}
175-
printk("VM: killing process %s\n", tsk->comm);
176-
if (user_mode(regs))
177-
do_group_exit(SIGKILL);
178-
goto no_context;
175+
if (!user_mode(regs))
176+
goto no_context;
177+
pagefault_out_of_memory();
178+
return;
179179

180180
do_sigbus:
181181
up_read(&mm->mmap_sem);

arch/tile/mm/fault.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -573,10 +573,10 @@ static int handle_page_fault(struct pt_regs *regs,
573573
down_read(&mm->mmap_sem);
574574
goto survive;
575575
}
576-
pr_alert("VM: killing process %s\n", tsk->comm);
577-
if (!is_kernel_mode)
578-
do_group_exit(SIGKILL);
579-
goto no_context;
576+
if (is_kernel_mode)
577+
goto no_context;
578+
pagefault_out_of_memory();
579+
return 0;
580580

581581
do_sigbus:
582582
up_read(&mm->mmap_sem);

0 commit comments

Comments
 (0)