Skip to content

Commit

Permalink
mm: invoke oom-killer from remaining unconverted page fault handlers
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
hnaz authored and torvalds committed Jul 9, 2013
1 parent 54f72fe commit 609838c
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 19 deletions.
6 changes: 4 additions & 2 deletions arch/arc/mm/fault.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,10 @@ void do_page_fault(struct pt_regs *regs, unsigned long address)
}
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;

Expand Down
6 changes: 4 additions & 2 deletions arch/metag/mm/fault.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,10 @@ int do_page_fault(struct pt_regs *regs, unsigned long address,
*/
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? */
Expand Down
7 changes: 4 additions & 3 deletions arch/mn10300/mm/fault.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,9 +345,10 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long fault_code,
*/
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:
Expand Down
8 changes: 4 additions & 4 deletions arch/openrisc/mm/fault.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,10 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long address,
__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);
Expand Down
8 changes: 4 additions & 4 deletions arch/score/mm/fault.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,10 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long write,
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);
Expand Down
8 changes: 4 additions & 4 deletions arch/tile/mm/fault.c
Original file line number Diff line number Diff line change
Expand Up @@ -573,10 +573,10 @@ static int handle_page_fault(struct pt_regs *regs,
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);
Expand Down

0 comments on commit 609838c

Please sign in to comment.