[Devel] [PATCH rh7] memcg: do not loop in mem_cgroup_reclaim if killed

Vladimir Davydov vdavydov at parallels.com
Tue Sep 8 03:43:32 PDT 2015


If try_to_free_mem_cgroup_pages is called by a killed process, it will
always return > 0 w/o even trying to reclaim anything. So we should give
up immediately if killed instead of calling it over and over again in
vain.

Signed-off-by: Vladimir Davydov <vdavydov at parallels.com>
---
 mm/memcontrol.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 6a0751f878d3..330cee7c8d38 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -2042,6 +2042,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))
+			return 1;
 		/*
 		 * Allow limit shrinkers, which are triggered directly
 		 * by userspace, to catch signals and stop reclaim
-- 
2.1.4




More information about the Devel mailing list