[Devel] [PATCH RHEL7 COMMIT] mm/memcontrol: remove excess put of memory cgroup id refcount on css free
Konstantin Khorenko
khorenko at virtuozzo.com
Wed Jul 12 11:54:57 MSK 2023
The commit is pushed to "branch-rh7-3.10.0-1160.90.1.vz7.200.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1160.90.1.vz7.200.6
------>
commit 8143311fffd3eabcfdbc0f4b191812fe9d7156d2
Author: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
Date: Tue Jul 11 12:32:03 2023 +0800
mm/memcontrol: remove excess put of memory cgroup id refcount on css free
The removed hunk comes from rhel partial porting of [1], there they
added mem_cgroup_id_put on memcg free instead of offline. But they also
didn't do refcounting in mem_cgroup_id_put, only removed id from idr.
Now we do actual refcounting in mem_cgroup_id_put, and atomic_set(1) and
css_get in mem_cgroup_css_online are paired with mem_cgroup_id_put in
mem_cgroup_css_offline. The call in free path is excess and we should
remove it.
This is not a critical excess refcount put, as it happened on late
cgroup freeing stage, which can only happen after this id refcount
reaches zero, which leads to css_put, which leads to freeing. So nobody
cares about id refcount at this point.
https://jira.vzint.dev/browse/PSBM-148818
mFixes: 9dcef96ce3e2 ("ms/mm: memcontrol: fix cgroup creation failure after many
small jobs") [1]
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
=================
Patchset description:
memcg: fixes for memory cgroup id refcounting
Complete memcg id refcount design:
- on cgroup online get css refcount and set memcg id refctount to 1
- on cgroup offline put memcg id refcount
- on swapout:
- if cgroup memcg id refcount is 0 (not online), use parent cgroup
- if cgroup memcg id refcount is >0, get it
(previously in rh7 we got css refcount instead)
- on swapin put memcg id refcount
(previously in rh7 we put css refcount instead)
- on charge move from one to another cgroup put memcg id refctount on
"from" cgroup and get it on "to" cgroup
(previously in rh7 we put css refcount on "from" and get on "to")
- on last memcg id refctount put also put css refcount
Charge move is a bit tricky: we get "to" memcg id refcount in
mem_cgroup_move_charge_pte_range, and put "from" memcg id refcount later
in __mem_cgroup_clear_mc.
So, in the first patch of this series we remove leftover memcg id
refcount put on memcg free path, and in the second patch we remove
leftover "to" css refcount get in task move code for moved swap.
https://jira.vzint.dev/browse/PSBM-148818
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
Pavel Tikhomirov (2):
mm/memcontrol: remove excess put of memory cgroup id refcount on css
free
mm/memcontrol: remove excess css_get on task migration with swap
---
mm/memcontrol.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 3a5e89b913bd..c7c15c6dd6fb 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -6818,8 +6818,6 @@ 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);
More information about the Devel
mailing list