提交 cef1d352 编写于 作者: K KOSAKI Motohiro 提交者: Linus Torvalds

oom: multi threaded process coredump don't make deadlock

Oleg pointed out current PF_EXITING check is wrong. Because PF_EXITING
is per-thread flag, not per-process flag. He said,

   Two threads, group-leader L and its sub-thread T. T dumps the code.
   In this case both threads have ->mm != NULL, L has PF_EXITING.

   The first problem is, select_bad_process() always return -1 in this
   case (even if the caller is T, this doesn't matter).

   The second problem is that we should add TIF_MEMDIE to T, not L.

I think we can remove this dubious PF_EXITING check. but as first step,
This patch add the protection of multi threaded issue.
Signed-off-by: NKOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Minchan Kim <minchan.kim@gmail.com>
Cc: David Rientjes <rientjes@google.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 93b43fa5
...@@ -360,7 +360,7 @@ static struct task_struct *select_bad_process(unsigned long *ppoints, ...@@ -360,7 +360,7 @@ static struct task_struct *select_bad_process(unsigned long *ppoints,
* the process of exiting and releasing its resources. * the process of exiting and releasing its resources.
* Otherwise we could get an easy OOM deadlock. * Otherwise we could get an easy OOM deadlock.
*/ */
if ((p->flags & PF_EXITING) && p->mm) { if (thread_group_empty(p) && (p->flags & PF_EXITING) && p->mm) {
if (p != current) if (p != current)
return ERR_PTR(-1UL); return ERR_PTR(-1UL);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册