@@ -55,7 +55,6 @@ struct list_lru {
#ifdef CONFIG_MEMCG_KMEM
struct list_head list;
int shrinker_id;
- bool memcg_aware;
/* for cgroup aware lrus points to per cgroup lists, otherwise NULL */
struct list_lru_memcg __rcu *memcg_lrus;
#endif
@@ -20,7 +20,7 @@ static DEFINE_MUTEX(list_lrus_mutex);
static inline bool list_lru_memcg_aware(struct list_lru *lru)
{
- return lru->memcg_aware;
+ return !!rcu_access_pointer(lru->memcg_lrus);
}
static void list_lru_register(struct list_lru *lru)
@@ -73,7 +73,7 @@ list_lru_from_kmem(struct list_lru *lru, int nid, void *ptr,
struct list_lru_one *l = &nlru->lru;
struct mem_cgroup *memcg = NULL;
- if (!lru->memcg_lrus)
+ if (!list_lru_memcg_aware(lru))
goto out;
memcg = mem_cgroup_from_obj(ptr);
@@ -367,9 +367,10 @@ static int memcg_init_list_lru(struct list_lru *lru, bool memcg_aware)
struct list_lru_memcg *memcg_lrus;
int size = memcg_nr_cache_ids;
- lru->memcg_aware = memcg_aware;
- if (!memcg_aware)
+ if (!memcg_aware) {
+ lru->memcg_lrus = NULL;
return 0;
+ }
memcg_lrus = kvmalloc(sizeof(*memcg_lrus) +
size * sizeof(memcg_lrus->lrus[0]), GFP_KERNEL);
We can use ->memcg_lrus to indicate if the list_lru is memcg aware. So ->memcg_aware is redundant and just remove it. Signed-off-by: Muchun Song <songmuchun@bytedance.com> --- include/linux/list_lru.h | 1 - mm/list_lru.c | 9 +++++---- 2 files changed, 5 insertions(+), 5 deletions(-)