aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
Diffstat (limited to 'mm')
-rw-r--r--mm/oom_kill.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 0d8ad1ebd1d1..054ff47c4478 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -102,14 +102,19 @@ struct task_struct *find_lock_task_mm(struct task_struct *p)
102{ 102{
103 struct task_struct *t; 103 struct task_struct *t;
104 104
105 rcu_read_lock();
106
105 for_each_thread(p, t) { 107 for_each_thread(p, t) {
106 task_lock(t); 108 task_lock(t);
107 if (likely(t->mm)) 109 if (likely(t->mm))
108 return t; 110 goto found;
109 task_unlock(t); 111 task_unlock(t);
110 } 112 }
113 t = NULL;
114found:
115 rcu_read_unlock();
111 116
112 return NULL; 117 return t;
113} 118}
114 119
115/* return true if the task is not adequate as candidate victim task. */ 120/* return true if the task is not adequate as candidate victim task. */
@@ -461,10 +466,8 @@ void oom_kill_process(struct task_struct *p, gfp_t gfp_mask, int order,
461 } 466 }
462 read_unlock(&tasklist_lock); 467 read_unlock(&tasklist_lock);
463 468
464 rcu_read_lock();
465 p = find_lock_task_mm(victim); 469 p = find_lock_task_mm(victim);
466 if (!p) { 470 if (!p) {
467 rcu_read_unlock();
468 put_task_struct(victim); 471 put_task_struct(victim);
469 return; 472 return;
470 } else if (victim != p) { 473 } else if (victim != p) {
@@ -490,6 +493,7 @@ void oom_kill_process(struct task_struct *p, gfp_t gfp_mask, int order,
490 * That thread will now get access to memory reserves since it has a 493 * That thread will now get access to memory reserves since it has a
491 * pending fatal signal. 494 * pending fatal signal.
492 */ 495 */
496 rcu_read_lock();
493 for_each_process(p) 497 for_each_process(p)
494 if (p->mm == mm && !same_thread_group(p, victim) && 498 if (p->mm == mm && !same_thread_group(p, victim) &&
495 !(p->flags & PF_KTHREAD)) { 499 !(p->flags & PF_KTHREAD)) {