[PATCH 08/17] mm: list_lru: remove memcg_aware from struct list_lru

From: Muchun Song
Date: Tue May 11 2021 - 06:52:17 EST


We can use ->memcg_lrus to indicate if the lru is memcg aware. So
->memcg_aware is redundant and remove it.

Signed-off-by: Muchun Song <songmuchun@xxxxxxxxxxxxx>
---
include/linux/list_lru.h | 1 -
mm/list_lru.c | 9 +++++----
2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/linux/list_lru.h b/include/linux/list_lru.h
index 228bef9fdd0b..00a13ad6128a 100644
--- a/include/linux/list_lru.h
+++ b/include/linux/list_lru.h
@@ -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
diff --git a/mm/list_lru.c b/mm/list_lru.c
index 57c55916cc1c..cf17ff5a5940 100644
--- a/mm/list_lru.c
+++ b/mm/list_lru.c
@@ -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 !!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);
@@ -368,9 +368,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);
--
2.11.0