aboutsummaryrefslogtreecommitdiffstats
path: root/mm/oom_kill.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/oom_kill.c')
-rw-r--r--mm/oom_kill.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index a5493a3b4851..20f41b082e16 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -216,6 +216,18 @@ static struct task_struct *select_bad_process(unsigned long *ppoints)
216 continue; 216 continue;
217 217
218 /* 218 /*
219 * This task already has access to memory reserves and is
220 * being killed. Don't allow any other task access to the
221 * memory reserve.
222 *
223 * Note: this may have a chance of deadlock if it gets
224 * blocked waiting for another task which itself is waiting
225 * for memory. Is there a better alternative?
226 */
227 if (test_tsk_thread_flag(p, TIF_MEMDIE))
228 return ERR_PTR(-1UL);
229
230 /*
219 * This is in the process of releasing memory so wait for it 231 * This is in the process of releasing memory so wait for it
220 * to finish before killing some other task by mistake. 232 * to finish before killing some other task by mistake.
221 * 233 *
@@ -223,16 +235,15 @@ static struct task_struct *select_bad_process(unsigned long *ppoints)
223 * go ahead if it is exiting: this will simply set TIF_MEMDIE, 235 * go ahead if it is exiting: this will simply set TIF_MEMDIE,
224 * which will allow it to gain access to memory reserves in 236 * which will allow it to gain access to memory reserves in
225 * the process of exiting and releasing its resources. 237 * the process of exiting and releasing its resources.
226 * Otherwise we could get an OOM deadlock. 238 * Otherwise we could get an easy OOM deadlock.
227 */ 239 */
228 if ((p->flags & PF_EXITING) && p == current) { 240 if (p->flags & PF_EXITING) {
241 if (p != current)
242 return ERR_PTR(-1UL);
243
229 chosen = p; 244 chosen = p;
230 *ppoints = ULONG_MAX; 245 *ppoints = ULONG_MAX;
231 break;
232 } 246 }
233 if ((p->flags & PF_EXITING) ||
234 test_tsk_thread_flag(p, TIF_MEMDIE))
235 return ERR_PTR(-1UL);
236 247
237 if (p->oomkilladj == OOM_DISABLE) 248 if (p->oomkilladj == OOM_DISABLE)
238 continue; 249 continue;