[PATCH v3 71/76] mm: list_lru: rename memcg_drain_all_list_lrus to memcg_reparent_list_lrus
From: Muchun Song
Date: Tue Sep 14 2021 - 03:46:10 EST
The purpose of the memcg_drain_all_list_lrus() is list_lrus reparenting.
It is very similar to memcg_reparent_objcgs(). Rename it to
memcg_reparent_list_lrus() so that the name can more consistent with
memcg_reparent_objcgs().
Signed-off-by: Muchun Song <songmuchun@xxxxxxxxxxxxx>
---
include/linux/list_lru.h | 3 +--
mm/list_lru.c | 25 ++++++++++++-------------
mm/memcontrol.c | 4 ++--
3 files changed, 15 insertions(+), 17 deletions(-)
diff --git a/include/linux/list_lru.h b/include/linux/list_lru.h
index 62f407831b8c..5e9c632c9eb7 100644
--- a/include/linux/list_lru.h
+++ b/include/linux/list_lru.h
@@ -77,8 +77,7 @@ int __list_lru_init(struct list_lru *lru, bool memcg_aware,
__list_lru_init((lru), true, NULL, shrinker)
int memcg_update_all_list_lrus(int num_memcgs);
-void memcg_drain_all_list_lrus(struct mem_cgroup *src_memcg,
- struct mem_cgroup *dst_memcg);
+void memcg_reparent_list_lrus(struct mem_cgroup *memcg, struct mem_cgroup *parent);
/**
* list_lru_add: add an element to the lru list's tail
diff --git a/mm/list_lru.c b/mm/list_lru.c
index 48651c29a9d1..1e42d9847b08 100644
--- a/mm/list_lru.c
+++ b/mm/list_lru.c
@@ -460,8 +460,8 @@ int memcg_update_all_list_lrus(int new_size)
return ret;
}
-static void memcg_drain_list_lru_node(struct list_lru *lru, int nid,
- int src_idx, struct mem_cgroup *dst_memcg)
+static void memcg_reparent_list_lru_node(struct list_lru *lru, int nid,
+ int src_idx, struct mem_cgroup *dst_memcg)
{
struct list_lru_node *nlru = &lru->node[nid];
int dst_idx = dst_memcg->kmemcg_id;
@@ -489,23 +489,22 @@ static void memcg_drain_list_lru_node(struct list_lru *lru, int nid,
spin_unlock_irq(&nlru->lock);
}
-static void memcg_drain_list_lru(struct list_lru *lru,
- int src_idx, struct mem_cgroup *dst_memcg)
+static void memcg_reparent_list_lru(struct list_lru *lru,
+ int src_idx, struct mem_cgroup *dst_memcg)
{
int i;
for_each_node(i)
- memcg_drain_list_lru_node(lru, i, src_idx, dst_memcg);
+ memcg_reparent_list_lru_node(lru, i, src_idx, dst_memcg);
memcg_list_lru_free(lru, src_idx);
}
-void memcg_drain_all_list_lrus(struct mem_cgroup *src_memcg,
- struct mem_cgroup *dst_memcg)
+void memcg_reparent_list_lrus(struct mem_cgroup *memcg, struct mem_cgroup *parent)
{
struct cgroup_subsys_state *css;
struct list_lru *lru;
- int src_idx = src_memcg->kmemcg_id;
+ int src_idx = memcg->kmemcg_id;
/*
* Change kmemcg_id of this cgroup and all its descendants to the
@@ -520,17 +519,17 @@ void memcg_drain_all_list_lrus(struct mem_cgroup *src_memcg,
* memcg_list_lru_free().
*/
rcu_read_lock();
- css_for_each_descendant_pre(css, &src_memcg->css) {
- struct mem_cgroup *memcg;
+ css_for_each_descendant_pre(css, &memcg->css) {
+ struct mem_cgroup *child;
- memcg = mem_cgroup_from_css(css);
- memcg->kmemcg_id = dst_memcg->kmemcg_id;
+ child = mem_cgroup_from_css(css);
+ child->kmemcg_id = parent->kmemcg_id;
}
rcu_read_unlock();
mutex_lock(&list_lrus_mutex);
list_for_each_entry(lru, &memcg_list_lrus, list)
- memcg_drain_list_lru(lru, src_idx, dst_memcg);
+ memcg_reparent_list_lru(lru, src_idx, parent);
mutex_unlock(&list_lrus_mutex);
}
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 2045cd8b1d7f..4cf98de2ad09 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -3636,12 +3636,12 @@ static void memcg_offline_kmem(struct mem_cgroup *memcg)
memcg_reparent_objcgs(memcg, parent);
/*
- * memcg_drain_all_list_lrus() can change memcg->kmemcg_id.
+ * memcg_reparent_list_lrus() can change memcg->kmemcg_id.
* Cache it to @kmemcg_id.
*/
kmemcg_id = memcg->kmemcg_id;
- memcg_drain_all_list_lrus(memcg, parent);
+ memcg_reparent_list_lrus(memcg, parent);
memcg_free_cache_id(kmemcg_id);
}
--
2.11.0