All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch] oom, memcg: fix exclusion of memcg threads after they have detached their mm
@ 2011-12-14  0:59 ` David Rientjes
  0 siblings, 0 replies; 18+ messages in thread
From: David Rientjes @ 2011-12-14  0:59 UTC (permalink / raw)
  To: Johannes Weiner, Michal Hocko, Balbir Singh, KAMEZAWA Hiroyuki
  Cc: cgroups-u79uwXL29TY76Z2rM5mHXA, linux-mm-Bw31MaZKKs3YtjvyW6yDsg

The oom killer relies on logic that identifies threads that have already
been oom killed when scanning the tasklist and, if found, deferring until
such threads have exited.  This is done by checking for any candidate
threads that have the TIF_MEMDIE bit set.

For memcg ooms, candidate threads are first found by calling
task_in_mem_cgroup() since the oom killer should not defer if there's an
oom killed thread in another memcg.

Unfortunately, task_in_mem_cgroup() excludes threads if they have
detached their mm in the process of exiting so TIF_MEMDIE is never
detected for such conditions.  This is different for global, mempolicy,
and cpuset oom conditions where a detached mm is only excluded after
checking for TIF_MEMDIE and deferring, if necessary, in
select_bad_process().

The fix is to return true if a task has a detached mm but is still in the
memcg that is currently oom.  This will allow the oom killer to
appropriately defer rather than kill unnecessarily or, in the worst case,
panic the machine if nothing else is available to kill.

Signed-off-by: David Rientjes <rientjes-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
---
 mm/memcontrol.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1110,7 +1110,7 @@ int task_in_mem_cgroup(struct task_struct *task, const struct mem_cgroup *memcg)
 
 	p = find_lock_task_mm(task);
 	if (!p)
-		return 0;
+		return mem_cgroup_from_task(task) == memcg;
 	curr = try_get_mem_cgroup_from_mm(p->mm);
 	task_unlock(p);
 	if (!curr)
--
To unsubscribe from this list: send the line "unsubscribe cgroups" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2011-12-16  8:31 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-14  0:59 [patch] oom, memcg: fix exclusion of memcg threads after they have detached their mm David Rientjes
2011-12-14  0:59 ` David Rientjes
     [not found] ` <alpine.DEB.2.00.1112131659100.32369-X6Q0R45D7oAcqpCFd4KODRPsWskHk0ljAL8bYrjMMd8@public.gmane.org>
2011-12-14  1:06   ` KAMEZAWA Hiroyuki
2011-12-14  1:06     ` KAMEZAWA Hiroyuki
2011-12-14 10:29   ` Michal Hocko
2011-12-14 10:29     ` Michal Hocko
     [not found]     ` <20111214102942.GA11786-VqjxzfR4DlwKmadIfiO5sKVXKuFTiq87@public.gmane.org>
2011-12-15  2:39       ` [patch v2] " David Rientjes
2011-12-15  2:39         ` David Rientjes
     [not found]         ` <alpine.DEB.2.00.1112141838470.27595-X6Q0R45D7oAcqpCFd4KODRPsWskHk0ljAL8bYrjMMd8@public.gmane.org>
2011-12-15 14:19           ` KOSAKI Motohiro
2011-12-15 14:19             ` KOSAKI Motohiro
2011-12-15 15:59           ` Michal Hocko
2011-12-15 15:59             ` Michal Hocko
     [not found]             ` <20111215155926.GA22819-VqjxzfR4DlwKmadIfiO5sKVXKuFTiq87@public.gmane.org>
2011-12-15 21:36               ` [patch v3] " David Rientjes
2011-12-15 21:36                 ` David Rientjes
     [not found]                 ` <alpine.DEB.2.00.1112151335370.17878-X6Q0R45D7oAcqpCFd4KODRPsWskHk0ljAL8bYrjMMd8@public.gmane.org>
2011-12-15 22:18                   ` KAMEZAWA Hiroyuki
2011-12-15 22:18                     ` KAMEZAWA Hiroyuki
2011-12-16  8:31                   ` Michal Hocko
2011-12-16  8:31                     ` Michal Hocko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.