@@ -1635,8 +1635,8 @@ void obj_cgroup_uncharge(struct obj_cgroup *objcg, size_t size);
extern struct static_key_false memcg_kmem_enabled_key;
extern int memcg_nr_cache_ids;
-void memcg_get_cache_ids(void);
-void memcg_put_cache_ids(void);
+void memcg_list_lru_resize_lock(void);
+void memcg_list_lru_resize_unlock(void);
/*
* Helper macro to loop through all memcg-specific caches. Callers must still
@@ -1711,11 +1711,11 @@ static inline int memcg_cache_id(struct mem_cgroup *memcg)
return -1;
}
-static inline void memcg_get_cache_ids(void)
+static inline void memcg_list_lru_resize_lock(void)
{
}
-static inline void memcg_put_cache_ids(void)
+static inline void memcg_list_lru_resize_unlock(void)
{
}
@@ -640,7 +640,7 @@ int __list_lru_init(struct list_lru *lru, bool memcg_aware,
else
lru->shrinker_id = -1;
#endif
- memcg_get_cache_ids();
+ memcg_list_lru_resize_lock();
lru->node = kcalloc(nr_node_ids, sizeof(*lru->node), GFP_KERNEL);
if (!lru->node)
@@ -663,7 +663,7 @@ int __list_lru_init(struct list_lru *lru, bool memcg_aware,
list_lru_register(lru);
out:
- memcg_put_cache_ids();
+ memcg_list_lru_resize_unlock();
return err;
}
EXPORT_SYMBOL_GPL(__list_lru_init);
@@ -674,7 +674,7 @@ void list_lru_destroy(struct list_lru *lru)
if (!lru->node)
return;
- memcg_get_cache_ids();
+ memcg_list_lru_resize_lock();
list_lru_unregister(lru);
@@ -685,6 +685,6 @@ void list_lru_destroy(struct list_lru *lru)
#ifdef CONFIG_MEMCG_KMEM
lru->shrinker_id = -1;
#endif
- memcg_put_cache_ids();
+ memcg_list_lru_resize_unlock();
}
EXPORT_SYMBOL_GPL(list_lru_destroy);
@@ -367,12 +367,12 @@ static int kmemcg_max_id;
/* Protects memcg_nr_cache_ids */
static DECLARE_RWSEM(memcg_cache_ids_sem);
-void memcg_get_cache_ids(void)
+void memcg_list_lru_resize_lock(void)
{
down_read(&memcg_cache_ids_sem);
}
-void memcg_put_cache_ids(void)
+void memcg_list_lru_resize_unlock(void)
{
up_read(&memcg_cache_ids_sem);
}
The rwsem is held for writing during list lru arrays relocation and memcg_nr_cache_ids updates. Therefore memcg_get_cache_ids implies memcg_nr_cache_ids cannot be updated. It acts as a lock primitive. So rename it to a more suitable name. Signed-off-by: Muchun Song <songmuchun@bytedance.com> --- include/linux/memcontrol.h | 8 ++++---- mm/list_lru.c | 8 ++++---- mm/memcontrol.c | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-)