diff options
author | Nick Piggin <npiggin@suse.de> | 2009-01-06 17:38:59 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-01-06 18:58:58 -0500 |
commit | 1c0fe6e3bda0464728c23c8d84aa47567e8b716c (patch) | |
tree | 64f7903ee7757b14464e8a06bf91f5c4d5a8ba56 /arch/x86 | |
parent | 5bd1455c239672081d0e7f086e899b8cbc7a9844 (diff) |
mm: invoke oom-killer from page fault
Rather than have the pagefault handler kill a process directly if it gets
a VM_FAULT_OOM, have it call into the OOM killer.
With increasingly sophisticated oom behaviour (cpusets, memory cgroups,
oom killing throttling, oom priority adjustment or selective disabling,
panic on oom, etc), it's silly to unconditionally kill the faulting
process at page fault time. Create a hook for pagefault oom path to call
into instead.
Only converted x86 and uml so far.
[akpm@linux-foundation.org: make __out_of_memory() static]
[akpm@linux-foundation.org: fix comment]
Signed-off-by: Nick Piggin <npiggin@suse.de>
Cc: Jeff Dike <jdike@addtoit.com>
Acked-by: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/x86')
-rw-r--r-- | arch/x86/mm/fault.c | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c index 57ec8c86a877..9e268b6b204e 100644 --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c | |||
@@ -667,7 +667,6 @@ void __kprobes do_page_fault(struct pt_regs *regs, unsigned long error_code) | |||
667 | if (unlikely(in_atomic() || !mm)) | 667 | if (unlikely(in_atomic() || !mm)) |
668 | goto bad_area_nosemaphore; | 668 | goto bad_area_nosemaphore; |
669 | 669 | ||
670 | again: | ||
671 | /* | 670 | /* |
672 | * When running in the kernel we expect faults to occur only to | 671 | * When running in the kernel we expect faults to occur only to |
673 | * addresses in user space. All other faults represent errors in the | 672 | * addresses in user space. All other faults represent errors in the |
@@ -859,25 +858,14 @@ no_context: | |||
859 | oops_end(flags, regs, sig); | 858 | oops_end(flags, regs, sig); |
860 | #endif | 859 | #endif |
861 | 860 | ||
862 | /* | ||
863 | * We ran out of memory, or some other thing happened to us that made | ||
864 | * us unable to handle the page fault gracefully. | ||
865 | */ | ||
866 | out_of_memory: | 861 | out_of_memory: |
862 | /* | ||
863 | * We ran out of memory, call the OOM killer, and return the userspace | ||
864 | * (which will retry the fault, or kill us if we got oom-killed). | ||
865 | */ | ||
867 | up_read(&mm->mmap_sem); | 866 | up_read(&mm->mmap_sem); |
868 | if (is_global_init(tsk)) { | 867 | pagefault_out_of_memory(); |
869 | yield(); | 868 | return; |
870 | /* | ||
871 | * Re-lookup the vma - in theory the vma tree might | ||
872 | * have changed: | ||
873 | */ | ||
874 | goto again; | ||
875 | } | ||
876 | |||
877 | printk("VM: killing process %s\n", tsk->comm); | ||
878 | if (error_code & PF_USER) | ||
879 | do_group_exit(SIGKILL); | ||
880 | goto no_context; | ||
881 | 869 | ||
882 | do_sigbus: | 870 | do_sigbus: |
883 | up_read(&mm->mmap_sem); | 871 | up_read(&mm->mmap_sem); |