aboutsummaryrefslogtreecommitdiffstats
path: root/mm/oom_kill.c
diff options
context:
space:
mode:
authorDavid Rientjes <rientjes@google.com>2011-10-31 20:07:11 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-10-31 20:30:45 -0400
commit7b0d44fa49b1dcfdcf4897f12ddd12ddeab1a9d7 (patch)
treec840608f5266e4ba783f4c4405efe89b69ae5754 /mm/oom_kill.c
parentf660daac474c6f7c2d710100e29b3276a6f4db0a (diff)
oom: avoid killing kthreads if they assume the oom killed thread's mm
After selecting a task to kill, the oom killer iterates all processes and kills all other threads that share the same mm_struct in different thread groups. It would not otherwise be helpful to kill a thread if its memory would not be subsequently freed. A kernel thread, however, may assume a user thread's mm by using use_mm(). This is only temporary and should not result in sending a SIGKILL to that kthread. This patch ensures that only user threads and not kthreads are sent a SIGKILL if they share the same mm_struct as the oom killed task. Signed-off-by: David Rientjes <rientjes@google.com> Reviewed-by: Michal Hocko <mhocko@suse.cz> Reviewed-by: 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 'mm/oom_kill.c')
-rw-r--r--mm/oom_kill.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index d897262068e2..b0d8943bc9fd 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -439,7 +439,7 @@ static int oom_kill_task(struct task_struct *p, struct mem_cgroup *mem)
439 task_unlock(p); 439 task_unlock(p);
440 440
441 /* 441 /*
442 * Kill all processes sharing p->mm in other thread groups, if any. 442 * Kill all user processes sharing p->mm in other thread groups, if any.
443 * They don't get access to memory reserves or a higher scheduler 443 * They don't get access to memory reserves or a higher scheduler
444 * priority, though, to avoid depletion of all memory or task 444 * priority, though, to avoid depletion of all memory or task
445 * starvation. This prevents mm->mmap_sem livelock when an oom killed 445 * starvation. This prevents mm->mmap_sem livelock when an oom killed
@@ -449,7 +449,8 @@ static int oom_kill_task(struct task_struct *p, struct mem_cgroup *mem)
449 * signal. 449 * signal.
450 */ 450 */
451 for_each_process(q) 451 for_each_process(q)
452 if (q->mm == mm && !same_thread_group(q, p)) { 452 if (q->mm == mm && !same_thread_group(q, p) &&
453 !(q->flags & PF_KTHREAD)) {
453 task_lock(q); /* Protect ->comm from prctl() */ 454 task_lock(q); /* Protect ->comm from prctl() */
454 pr_err("Kill process %d (%s) sharing same memory\n", 455 pr_err("Kill process %d (%s) sharing same memory\n",
455 task_pid_nr(q), q->comm); 456 task_pid_nr(q), q->comm);