From: David Rientjes Date: Wed, 24 Aug 2011 23:46:49 +0000 (+1000) Subject: After selecting a task to kill, the oom killer iterates all processes and X-Git-Tag: next-20110912~1^2~88 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=8aad181756b931c7f222b90198482c90bd5789ba;p=karo-tx-linux.git 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 Reviewed-by: Michal Hocko Reviewed-by: KOSAKI Motohiro Signed-off-by: Andrew Morton --- diff --git a/mm/oom_kill.c b/mm/oom_kill.c index 626303b52f3c..64bccffb848e 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -435,7 +435,7 @@ static int oom_kill_task(struct task_struct *p, struct mem_cgroup *mem) task_unlock(p); /* - * Kill all processes sharing p->mm in other thread groups, if any. + * Kill all user processes sharing p->mm in other thread groups, if any. * They don't get access to memory reserves or a higher scheduler * priority, though, to avoid depletion of all memory or task * starvation. This prevents mm->mmap_sem livelock when an oom killed @@ -445,7 +445,8 @@ static int oom_kill_task(struct task_struct *p, struct mem_cgroup *mem) * signal. */ for_each_process(q) - if (q->mm == mm && !same_thread_group(q, p)) { + if (q->mm == mm && !same_thread_group(q, p) && + !(q->flags & PF_KTHREAD)) { task_lock(q); /* Protect ->comm from prctl() */ pr_err("Kill process %d (%s) sharing same memory\n", task_pid_nr(q), q->comm);