]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/3.10.61/arch-mm-remove-obsolete-init-oom-protection.patch
drop queue-4.19/drm-amdgpu-soc15-skip-reset-on-init.patch
[thirdparty/kernel/stable-queue.git] / releases / 3.10.61 / arch-mm-remove-obsolete-init-oom-protection.patch
1 From 94bce453c78996cc4373d5da6cfabe07fcc6d9f9 Mon Sep 17 00:00:00 2001
2 From: Johannes Weiner <hannes@cmpxchg.org>
3 Date: Thu, 12 Sep 2013 15:13:36 -0700
4 Subject: arch: mm: remove obsolete init OOM protection
5
6 From: Johannes Weiner <hannes@cmpxchg.org>
7
8 commit 94bce453c78996cc4373d5da6cfabe07fcc6d9f9 upstream.
9
10 The memcg code can trap tasks in the context of the failing allocation
11 until an OOM situation is resolved. They can hold all kinds of locks
12 (fs, mm) at this point, which makes it prone to deadlocking.
13
14 This series converts memcg OOM handling into a two step process that is
15 started in the charge context, but any waiting is done after the fault
16 stack is fully unwound.
17
18 Patches 1-4 prepare architecture handlers to support the new memcg
19 requirements, but in doing so they also remove old cruft and unify
20 out-of-memory behavior across architectures.
21
22 Patch 5 disables the memcg OOM handling for syscalls, readahead, kernel
23 faults, because they can gracefully unwind the stack with -ENOMEM. OOM
24 handling is restricted to user triggered faults that have no other
25 option.
26
27 Patch 6 reworks memcg's hierarchical OOM locking to make it a little
28 more obvious wth is going on in there: reduce locked regions, rename
29 locking functions, reorder and document.
30
31 Patch 7 implements the two-part OOM handling such that tasks are never
32 trapped with the full charge stack in an OOM situation.
33
34 This patch:
35
36 Back before smart OOM killing, when faulting tasks were killed directly on
37 allocation failures, the arch-specific fault handlers needed special
38 protection for the init process.
39
40 Now that all fault handlers call into the generic OOM killer (see commit
41 609838cfed97: "mm: invoke oom-killer from remaining unconverted page
42 fault handlers"), which already provides init protection, the
43 arch-specific leftovers can be removed.
44
45 Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
46 Reviewed-by: Michal Hocko <mhocko@suse.cz>
47 Acked-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
48 Cc: David Rientjes <rientjes@google.com>
49 Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
50 Cc: azurIt <azurit@pobox.sk>
51 Acked-by: Vineet Gupta <vgupta@synopsys.com> [arch/arc bits]
52 Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
53 Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
54 Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
55 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
56
57 ---
58 arch/arc/mm/fault.c | 5 -----
59 arch/score/mm/fault.c | 6 ------
60 arch/tile/mm/fault.c | 6 ------
61 3 files changed, 17 deletions(-)
62
63 --- a/arch/arc/mm/fault.c
64 +++ b/arch/arc/mm/fault.c
65 @@ -120,7 +120,6 @@ good_area:
66 goto bad_area;
67 }
68
69 -survive:
70 /*
71 * If for any reason at all we couldn't handle the fault,
72 * make sure we exit gracefully rather than endlessly redo
73 @@ -200,10 +199,6 @@ no_context:
74 die("Oops", regs, address, cause_code);
75
76 out_of_memory:
77 - if (is_global_init(tsk)) {
78 - yield();
79 - goto survive;
80 - }
81 up_read(&mm->mmap_sem);
82
83 if (user_mode(regs)) {
84 --- a/arch/score/mm/fault.c
85 +++ b/arch/score/mm/fault.c
86 @@ -100,7 +100,6 @@ good_area:
87 goto bad_area;
88 }
89
90 -survive:
91 /*
92 * If for any reason at all we couldn't handle the fault,
93 * make sure we exit gracefully rather than endlessly redo
94 @@ -167,11 +166,6 @@ no_context:
95 */
96 out_of_memory:
97 up_read(&mm->mmap_sem);
98 - if (is_global_init(tsk)) {
99 - yield();
100 - down_read(&mm->mmap_sem);
101 - goto survive;
102 - }
103 if (!user_mode(regs))
104 goto no_context;
105 pagefault_out_of_memory();
106 --- a/arch/tile/mm/fault.c
107 +++ b/arch/tile/mm/fault.c
108 @@ -430,7 +430,6 @@ good_area:
109 goto bad_area;
110 }
111
112 - survive:
113 /*
114 * If for any reason at all we couldn't handle the fault,
115 * make sure we exit gracefully rather than endlessly redo
116 @@ -568,11 +567,6 @@ no_context:
117 */
118 out_of_memory:
119 up_read(&mm->mmap_sem);
120 - if (is_global_init(tsk)) {
121 - yield();
122 - down_read(&mm->mmap_sem);
123 - goto survive;
124 - }
125 if (is_kernel_mode)
126 goto no_context;
127 pagefault_out_of_memory();