[Devel] [PATCH rh7] mm/memcg: add missing kmem charge.

Andrey Ryabinin aryabinin at virtuozzo.com
Tue Aug 29 18:13:17 MSK 2017


Since de3a106e28d5 ("mm/memcg: reclaim memory on reaching kmem limit.")
if try_charge() decide to bypass memory limit, mem_cgroup_charge_kmem()
will charge only ->memory/->memsw but not ->kmem. This may lead to
deadlocks during cgroup destruction as condition:
	 (page_counter_read(&memcg->memory) -
	 page_counter_read(&memcg->kmem) > 0)

in mem_cgroup_reparent_charges() won't come true ever.

https://jira.sw.ru/browse/PSBM-70556
Fixes: de3a106e28d5 ("mm/memcg: reclaim memory on reaching kmem limit.")
Signed-off-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
---
 mm/memcontrol.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 5ab5e82c924e..49d4586c9d21 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -3087,6 +3087,8 @@ int memcg_charge_kmem(struct mem_cgroup *memcg, gfp_t gfp,
 		page_counter_charge(&memcg->memory, nr_pages);
 		if (do_swap_account)
 			page_counter_charge(&memcg->memsw, nr_pages);
+		page_counter_charge(&memcg->kmem, nr_pages);
+
 		ret = 0;
 	}
 
-- 
2.13.5



More information about the Devel mailing list