oom: thaw threads if oom killed thread is frozen before deferring
authorDavid Rientjes <[email protected]>
Tue, 1 Nov 2011 00:07:07 +0000 (17:07 -0700)
committerLinus Torvalds <[email protected]>
Tue, 1 Nov 2011 00:30:45 +0000 (17:30 -0700)
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 <[email protected]>
Reported-by: Konstantin Khlebnikov <[email protected]>
Cc: Oleg Nesterov <[email protected]>
Cc: KOSAKI Motohiro <[email protected]>
Cc: KAMEZAWA Hiroyuki <[email protected]>
Cc: "Rafael J. Wysocki" <[email protected]>
Acked-by: Michal Hocko <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
mm/oom_kill.c

index 626303b52f3ce0764d3bb1029f6bce8b5bcaa896..d897262068e23e81d6ef880ed4096093a65d2410 100644 (file)
@@ -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;