| From f792e47c3aef0e6346cffbf2c578e4cc9a3e9490 Mon Sep 17 00:00:00 2001 |
| From: David Rientjes <rientjes@google.com> |
| Date: Mon, 31 Oct 2011 17:07:07 -0700 |
| Subject: oom: thaw threads if oom killed thread is frozen before deferring |
| |
| If a thread has been oom killed and is frozen, thaw it before returning to |
| the page allocator. Otherwise, it can stay frozen indefinitely and no |
| memory will be freed. |
| |
| Signed-off-by: David Rientjes <rientjes@google.com> |
| Reported-by: Konstantin Khlebnikov <khlebnikov@openvz.org> |
| Cc: Oleg Nesterov <oleg@redhat.com> |
| Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> |
| Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> |
| Cc: "Rafael J. Wysocki" <rjw@sisk.pl> |
| Acked-by: Michal Hocko <mhocko@suse.cz> |
| Signed-off-by: Andrew Morton <akpm@linux-foundation.org> |
| Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> |
| (cherry picked from commit f660daac474c6f7c2d710100e29b3276a6f4db0a) |
| |
| Signed-off-by: Simon Horman <horms@verge.net.au> |
| --- |
| mm/oom_kill.c | 6 +++++- |
| 1 file changed, 5 insertions(+), 1 deletion(-) |
| |
| diff --git a/mm/oom_kill.c b/mm/oom_kill.c |
| index 7c72487..d00e922 100644 |
| --- a/mm/oom_kill.c |
| +++ b/mm/oom_kill.c |
| @@ -32,6 +32,7 @@ |
| #include <linux/mempolicy.h> |
| #include <linux/security.h> |
| #include <linux/ptrace.h> |
| +#include <linux/freezer.h> |
| |
| int sysctl_panic_on_oom; |
| int sysctl_oom_kill_allocating_task; |
| @@ -317,8 +318,11 @@ static struct task_struct *select_bad_process(unsigned int *ppoints, |
| * blocked waiting for another task which itself is waiting |
| * for memory. Is there a better alternative? |
| */ |
| - if (test_tsk_thread_flag(p, TIF_MEMDIE)) |
| + if (test_tsk_thread_flag(p, TIF_MEMDIE)) { |
| + if (unlikely(frozen(p))) |
| + thaw_process(p); |
| return ERR_PTR(-1UL); |
| + } |
| if (!p->mm) |
| continue; |
| |
| -- |
| 1.7.10.1.362.g242cab3 |
| |