From: David Rientjes <rientjes@google.com>
Date: Tue, 10 Aug 2010 00:18:49 +0000 (-0700)
Subject: oom: avoid sending exiting tasks a SIGKILL
X-Git-Tag: v2.6.36-rc1~460
X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=4358997ae38a1901498d128d6508119d9f318b36;p=users%2Fdwmw2%2Flinux.git

oom: avoid sending exiting tasks a SIGKILL

It's unnecessary to SIGKILL a task that is already PF_EXITING and can
actually cause a NULL pointer dereference of the sighand if it has already
been detached.  Instead, simply set TIF_MEMDIE so it has access to memory
reserves and can quickly exit as the comment implies.

Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Signed-off-by: David Rientjes <rientjes@google.com>
Cc: 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>
---

diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 64cdacad83d92..0c7c18f784251 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -453,7 +453,7 @@ static int oom_kill_process(struct task_struct *p, gfp_t gfp_mask, int order,
 	 * its children or threads, just set TIF_MEMDIE so it can die quickly
 	 */
 	if (p->flags & PF_EXITING) {
-		__oom_kill_task(p, 0);
+		set_tsk_thread_flag(p, TIF_MEMDIE);
 		return 0;
 	}