[Devel] [PATCH RHEL7 COMMIT] ms/oom: thaw the OOM victim if it is frozen

Konstantin Khorenko khorenko at virtuozzo.com
Thu Oct 15 06:47:35 PDT 2015


The commit is pushed to "branch-rh7-3.10.0-229.7.2.vz7.8.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-229.7.2.vz7.8.6
------>
commit 880e147721e60945828b460b86f36057e72603df
Author: Vladimir Davydov <vdavydov at parallels.com>
Date:   Thu Oct 15 17:47:35 2015 +0400

    ms/oom: thaw the OOM victim if it is frozen
    
    Patchset description: oom enhancements - part 1
    
    Pull mainstream patches that clean up TIF_MEMDIE handling. They will
    come in handy for the upcoming oom rework.
    
    https://jira.sw.ru/browse/PSBM-26973
    
    David Rientjes (1):
      mm, oom: remove unnecessary exit_state check
    
    Johannes Weiner (1):
      mm: oom_kill: clean up victim marking and exiting interfaces
    
    Michal Hocko (3):
      oom: make sure that TIF_MEMDIE is set under task_lock
      oom: add helpers for setting and clearing TIF_MEMDIE
      oom: thaw the OOM victim if it is frozen
    
    Tetsuo Handa (1):
      oom: don't count on mm-less current process
    
    ===============================================
    This patch desciption:
    
    From: Michal Hocko <mhocko at suse.cz>
    
    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 <mhocko at suse.cz>
    Cc: Tejun Heo <tj at kernel.org>
    Cc: David Rientjes <rientjes at google.com>
    Cc: Johannes Weiner <hannes at cmpxchg.org>
    Cc: Oleg Nesterov <oleg at redhat.com>
    Cc: Cong Wang <xiyou.wangcong at gmail.com>
    Cc: "Rafael J. Wysocki" <rjw at rjwysocki.net>
    Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>
    (cherry picked from commit 63a8ca9b2084fa5bd91aa380532f18e361764109)
    Signed-off-by: Vladimir Davydov <vdavydov at parallels.com>
    
    Reviewed-by: Kirill Tkhai <ktkhai at odin.com>
---
 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 224dd8d..7b106e8 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -266,8 +266,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);
 		if (!force_kill)
 			return OOM_SCAN_ABORT;
 	}
@@ -417,6 +415,14 @@ static void dump_header(struct task_struct *p, gfp_t gfp_mask, int order,
 void mark_tsk_oom_victim(struct task_struct *tsk)
 {
 	set_tsk_thread_flag(tsk, 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(tsk);
 }
 
 /**



More information about the Devel mailing list