aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um
diff options
context:
space:
mode:
authorJohannes Weiner <hannes@cmpxchg.org>2013-09-12 18:13:39 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-09-12 18:38:01 -0400
commit759496ba6407c6994d6a5ce3a5e74937d7816208 (patch)
treeaeff8de8af36f70f2591114cef58c9ae7df25565 /arch/um
parent871341023c771ad233620b7a1fb3d9c7031c4e5c (diff)
arch: mm: pass userspace fault flag to generic fault handler
Unlike global OOM handling, memory cgroup code will invoke the OOM killer in any OOM situation because it has no way of telling faults occuring in kernel context - which could be handled more gracefully - from user-triggered faults. Pass a flag that identifies faults originating in user space from the architecture-specific fault handlers to generic code so that memcg OOM handling can be improved. Signed-off-by: Johannes Weiner <hannes@cmpxchg.org> Reviewed-by: Michal Hocko <mhocko@suse.cz> Cc: David Rientjes <rientjes@google.com> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: azurIt <azurit@pobox.sk> Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/um')
-rw-r--r--arch/um/kernel/trap.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/arch/um/kernel/trap.c b/arch/um/kernel/trap.c
index b2f5adf838dd..5c3aef74237f 100644
--- a/arch/um/kernel/trap.c
+++ b/arch/um/kernel/trap.c
@@ -30,8 +30,7 @@ int handle_page_fault(unsigned long address, unsigned long ip,
30 pmd_t *pmd; 30 pmd_t *pmd;
31 pte_t *pte; 31 pte_t *pte;
32 int err = -EFAULT; 32 int err = -EFAULT;
33 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE | 33 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
34 (is_write ? FAULT_FLAG_WRITE : 0);
35 34
36 *code_out = SEGV_MAPERR; 35 *code_out = SEGV_MAPERR;
37 36
@@ -42,6 +41,8 @@ int handle_page_fault(unsigned long address, unsigned long ip,
42 if (in_atomic()) 41 if (in_atomic())
43 goto out_nosemaphore; 42 goto out_nosemaphore;
44 43
44 if (is_user)
45 flags |= FAULT_FLAG_USER;
45retry: 46retry:
46 down_read(&mm->mmap_sem); 47 down_read(&mm->mmap_sem);
47 vma = find_vma(mm, address); 48 vma = find_vma(mm, address);
@@ -58,12 +59,15 @@ retry:
58 59
59good_area: 60good_area:
60 *code_out = SEGV_ACCERR; 61 *code_out = SEGV_ACCERR;
61 if (is_write && !(vma->vm_flags & VM_WRITE)) 62 if (is_write) {
62 goto out; 63 if (!(vma->vm_flags & VM_WRITE))
63 64 goto out;
64 /* Don't require VM_READ|VM_EXEC for write faults! */ 65 flags |= FAULT_FLAG_WRITE;
65 if (!is_write && !(vma->vm_flags & (VM_READ | VM_EXEC))) 66 } else {
66 goto out; 67 /* Don't require VM_READ|VM_EXEC for write faults! */
68 if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
69 goto out;
70 }
67 71
68 do { 72 do {
69 int fault; 73 int fault;