Commit b5227940 authored by Oleg Nesterov's avatar Oleg Nesterov Committed by Linus Torvalds

oom: PF_EXITING check should take mm into account

select_bad_process() checks PF_EXITING to detect the task which is going
to release its memory, but the logic is very wrong.

	- a single process P with the dead group leader disables
	  select_bad_process() completely, it will always return
	  ERR_PTR() while P can live forever

	- if the PF_EXITING task has already released its ->mm
	  it doesn't make sense to expect it is goiing to free
	  more memory (except task_struct/etc)

Change the code to ignore the PF_EXITING tasks without ->mm.
Signed-off-by: default avatarOleg Nesterov <oleg@redhat.com>
Signed-off-by: default avatarDavid Rientjes <rientjes@google.com>
Cc: Balbir Singh <balbir@in.ibm.com>
Acked-by: default avatarKOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 455c0e5f
...@@ -287,7 +287,7 @@ static struct task_struct *select_bad_process(unsigned long *ppoints, ...@@ -287,7 +287,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) { if ((p->flags & PF_EXITING) && p->mm) {
if (p != current) if (p != current)
return ERR_PTR(-1UL); return ERR_PTR(-1UL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment