Skip to content

Commit 6426886

Browse files
Muchun Songtorvalds
authored andcommitted
mm: memcontrol: remove kmemcg_id reparenting
Since slab objects and kmem pages are charged to object cgroup instead of memory cgroup, memcg_reparent_objcgs() will reparent this cgroup and all its descendants to its parent cgroup. This already makes further list_lru_add()'s add elements to the parent's list. So it is unnecessary to change kmemcg_id of an offline cgroup to its parent's id. It just wastes CPU cycles. Just remove the redundant code. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Muchun Song <[email protected]> Acked-by: Roman Gushchin <[email protected]> Cc: Johannes Weiner <[email protected]> Cc: Matthew Wilcox (Oracle) <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Shakeel Butt <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 41d1743 commit 6426886

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

mm/memcontrol.c

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3650,8 +3650,7 @@ static int memcg_online_kmem(struct mem_cgroup *memcg)
36503650

36513651
static void memcg_offline_kmem(struct mem_cgroup *memcg)
36523652
{
3653-
struct cgroup_subsys_state *css;
3654-
struct mem_cgroup *parent, *child;
3653+
struct mem_cgroup *parent;
36553654
int kmemcg_id;
36563655

36573656
if (memcg->kmem_state != KMEM_ONLINE)
@@ -3669,21 +3668,11 @@ static void memcg_offline_kmem(struct mem_cgroup *memcg)
36693668
BUG_ON(kmemcg_id < 0);
36703669

36713670
/*
3672-
* Change kmemcg_id of this cgroup and all its descendants to the
3673-
* parent's id, and then move all entries from this cgroup's list_lrus
3674-
* to ones of the parent. After we have finished, all list_lrus
3675-
* corresponding to this cgroup are guaranteed to remain empty. The
3676-
* ordering is imposed by list_lru_node->lock taken by
3671+
* After we have finished memcg_reparent_objcgs(), all list_lrus
3672+
* corresponding to this cgroup are guaranteed to remain empty.
3673+
* The ordering is imposed by list_lru_node->lock taken by
36773674
* memcg_drain_all_list_lrus().
36783675
*/
3679-
rcu_read_lock(); /* can be called from css_free w/o cgroup_mutex */
3680-
css_for_each_descendant_pre(css, &memcg->css) {
3681-
child = mem_cgroup_from_css(css);
3682-
BUG_ON(child->kmemcg_id != kmemcg_id);
3683-
child->kmemcg_id = parent->kmemcg_id;
3684-
}
3685-
rcu_read_unlock();
3686-
36873676
memcg_drain_all_list_lrus(kmemcg_id, parent);
36883677

36893678
memcg_free_cache_id(kmemcg_id);

0 commit comments

Comments
 (0)