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 <[email protected]> --- mm/memcontrol.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 9ccc8080c2e0..b2543e69ccf7 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -2088,7 +2088,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 @@ -2939,7 +2940,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; } -- 2.1.4 _______________________________________________ Devel mailing list [email protected] https://lists.openvz.org/mailman/listinfo/devel
