[Devel] [PATCH RHEL7 COMMIT] mm: memcontrol: check more carefully if current is oom killed

Konstantin Khorenko khorenko at virtuozzo.com
Fri Apr 29 08:28:58 PDT 2016


The commit is pushed to "branch-rh7-3.10.0-327.10.1.vz7.12.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-327.10.1.vz7.12.15
------>
commit 5948747c2342fb62d91d5a7dd7140e7922634a6b
Author: Vladimir Davydov <vdavydov at virtuozzo.com>
Date:   Fri Apr 29 19:28:58 2016 +0400

    mm: memcontrol: check more carefully if current is oom killed
    
    Currently, we abort memcg reclaim only if fatal_signal_pending returns
    true on current. That's not enough, because a process can be killed
    after it entered do_exit, in which case signal_pending may not be set
    and therefore an OOM killed process may be looping in mem_cgroup_reclaim
    for quite some time (the latter retries reclaim 100 times!), resulting
    in OOM timeout at best or soft lockup panic at worst.
    
    Let's elaborate the abort condition by adding TIF_MEMDIE check.
    
    Signed-off-by: Vladimir Davydov <vdavydov at virtuozzo.com>
    Reviewed-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 mm/memcontrol.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index df78ffd..a2ac582 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -2092,7 +2092,8 @@ static unsigned long mem_cgroup_reclaim(struct mem_cgroup *memcg,
 			drain_all_stock_async(memcg);
 		total += try_to_free_mem_cgroup_pages(memcg, SWAP_CLUSTER_MAX,
 						      gfp_mask, noswap);
-		if (fatal_signal_pending(current))
+		if (test_thread_flag(TIF_MEMDIE) ||
+		    fatal_signal_pending(current))
 			return 1;
 		/*
 		 * Allow limit shrinkers, which are triggered directly
@@ -2943,7 +2944,8 @@ again:
 		bool invoke_oom = oom && !nr_oom_retries;
 
 		/* If killed, bypass charge */
-		if (fatal_signal_pending(current)) {
+		if (test_thread_flag(TIF_MEMDIE) ||
+		    fatal_signal_pending(current)) {
 			css_put(&memcg->css);
 			goto bypass;
 		}


More information about the Devel mailing list