freezer, oom: check TIF_MEMDIE on the correct task
authorMichal Hocko <[email protected]>
Thu, 28 Jul 2016 22:45:16 +0000 (15:45 -0700)
committerLinus Torvalds <[email protected]>
Thu, 28 Jul 2016 23:07:41 +0000 (16:07 -0700)
freezing_slow_path() is checking TIF_MEMDIE to skip OOM killed tasks.
It is, however, checking the flag on the current task rather than the
given one.  This is really confusing because freezing() can be called
also on !current tasks.  It would end up working correctly for its main
purpose because __refrigerator will be always called on the current task
so the oom victim will never get frozen.  But it could lead to
surprising results when a task which is freezing a cgroup got oom killed
because only part of the cgroup would get frozen.  This is highly
unlikely but worth fixing as the resulting code would be more clear
anyway.

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Michal Hocko <[email protected]>
Cc: David Rientjes <[email protected]>
Cc: Miao Xie <[email protected]>
Cc: Miao Xie <[email protected]>
Cc: "Rafael J. Wysocki" <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
kernel/freezer.c

index a8900a3bc27a895b65580a23a144e581bfe0149d..6f56a9e219facf003d802bd1e9c0cd2dea9824d3 100644 (file)
@@ -42,7 +42,7 @@ bool freezing_slow_path(struct task_struct *p)
        if (p->flags & (PF_NOFREEZE | PF_SUSPEND_TASK))
                return false;
 
-       if (test_thread_flag(TIF_MEMDIE))
+       if (test_tsk_thread_flag(p, TIF_MEMDIE))
                return false;
 
        if (pm_nosig_freezing || cgroup_freezing(p))