From: Michal Hocko <[email protected]> oom_kill_process only sets TIF_MEMDIE flag and sends a signal to the victim. This is basically noop when the task is frozen though because the task sleeps in the uninterruptible sleep. The victim is eventually thawed later when oom_scan_process_thread meets the task again in a later OOM invocation so the OOM killer doesn't live lock. But this is less than optimal.
Let's add __thaw_task into mark_tsk_oom_victim after we set TIF_MEMDIE to the victim. We are not checking whether the task is frozen because that would be racy and __thaw_task does that already. oom_scan_process_thread doesn't need to care about freezer anymore as TIF_MEMDIE and freezer are excluded completely now. Signed-off-by: Michal Hocko <[email protected]> Cc: Tejun Heo <[email protected]> Cc: David Rientjes <[email protected]> Cc: Johannes Weiner <[email protected]> Cc: Oleg Nesterov <[email protected]> Cc: Cong Wang <[email protected]> Cc: "Rafael J. Wysocki" <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]> (cherry picked from commit 63a8ca9b2084fa5bd91aa380532f18e361764109) Signed-off-by: Vladimir Davydov <[email protected]> Conflicts: mm/oom_kill.c --- mm/oom_kill.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/mm/oom_kill.c b/mm/oom_kill.c index 0d569020390a..9ce3e021947e 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -269,8 +269,6 @@ enum oom_scan_t oom_scan_process_thread(struct task_struct *task, * Don't allow any other task to have access to the reserves. */ if (test_tsk_thread_flag(task, TIF_MEMDIE)) { - if (unlikely(frozen(task))) - __thaw_task(task); smp_rmb(); /* matches smp_wmb() in set_tsk_memdie() */ if (time_after(jiffies, task->memdie_start + sysctl_oom_timeout)) @@ -424,6 +422,14 @@ void set_tsk_memdie(struct task_struct *p) smp_wmb(); /* matches smp_rmb() in oom_scan_process_thread() */ set_tsk_thread_flag(p, TIF_MEMDIE); } + + /* + * Make sure that the task is woken up from uninterruptible sleep + * if it is frozen because OOM killer wouldn't be able to free + * any memory and livelock. freezing_slow_path will tell the freezer + * that TIF_MEMDIE tasks should be ignored. + */ + __thaw_task(p); } #define K(x) ((x) << (PAGE_SHIFT-10)) -- 2.1.4 _______________________________________________ Devel mailing list [email protected] https://lists.openvz.org/mailman/listinfo/devel
