[Devel] [PATCH RHEL7 v2] mm/memcg: Release memcg id from css_free callback

Konstantin Khorenko khorenko at virtuozzo.com
Tue May 14 15:41:54 MSK 2019


From: Andrey Ryabinin <aryabinin at virtuozzo.com>

This affectively reverts 9d784f49c1c5 ("Revert: [rh/mm]: delay memcg id
freeing")

After rebase to kernel-3.10.0-957.10.1.el7 memcg id freed
in memcg offline callback instead of free. This makes possible
to reuse id by another cgroup, thus mem_cgroup_uncharge_swap()
may call css_put() on the wrong cgroup.

Delay release of memcg id up to css_free() point.

https://jira.sw.ru/browse/PSBM-94269

Signed-off-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
Acked-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
 mm/memcontrol.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 5a0641a38835..4be20b81fcf8 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -6345,6 +6345,8 @@ static void __mem_cgroup_free(struct mem_cgroup *memcg)
 
 	mem_cgroup_remove_from_trees(memcg);
 
+	mem_cgroup_id_put(memcg);
+
 	for_each_node(node)
 		free_mem_cgroup_per_zone_info(memcg, node);
 
@@ -6573,8 +6575,6 @@ static void mem_cgroup_css_offline(struct cgroup *cont)
 	 * no longer iterate over it.
 	 */
 	release_oom_context(&memcg->oom_ctx);
-
-	mem_cgroup_id_put(memcg);
 }
 
 static void mem_cgroup_css_free(struct cgroup *cont)
-- 
2.15.1



More information about the Devel mailing list