Commit e80216d9 authored by Muchun Song's avatar Muchun Song Committed by Linus Torvalds

mm: memcontrol: remove the kmem states

Now the kmem states is only used to indicate whether the kmem is
offline.  However, we can set ->kmemcg_id to -1 to indicate whether the
kmem is offline.  Finally, we can remove the kmem states to simplify the
code.

Link: https://lkml.kernel.org/r/20211025125259.56624-1-songmuchun@bytedance.comSigned-off-by: default avatarMuchun Song <songmuchun@bytedance.com>
Acked-by: default avatarRoman Gushchin <guro@fb.com>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Shakeel Butt <shakeelb@google.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 64268868
...@@ -180,12 +180,6 @@ struct mem_cgroup_thresholds { ...@@ -180,12 +180,6 @@ struct mem_cgroup_thresholds {
struct mem_cgroup_threshold_ary *spare; struct mem_cgroup_threshold_ary *spare;
}; };
enum memcg_kmem_state {
KMEM_NONE,
KMEM_ALLOCATED,
KMEM_ONLINE,
};
#if defined(CONFIG_SMP) #if defined(CONFIG_SMP)
struct memcg_padding { struct memcg_padding {
char x[0]; char x[0];
...@@ -318,7 +312,6 @@ struct mem_cgroup { ...@@ -318,7 +312,6 @@ struct mem_cgroup {
#ifdef CONFIG_MEMCG_KMEM #ifdef CONFIG_MEMCG_KMEM
int kmemcg_id; int kmemcg_id;
enum memcg_kmem_state kmem_state;
struct obj_cgroup __rcu *objcg; struct obj_cgroup __rcu *objcg;
struct list_head objcg_list; /* list of inherited objcgs */ struct list_head objcg_list; /* list of inherited objcgs */
#endif #endif
......
...@@ -3626,7 +3626,6 @@ static int memcg_online_kmem(struct mem_cgroup *memcg) ...@@ -3626,7 +3626,6 @@ static int memcg_online_kmem(struct mem_cgroup *memcg)
return 0; return 0;
BUG_ON(memcg->kmemcg_id >= 0); BUG_ON(memcg->kmemcg_id >= 0);
BUG_ON(memcg->kmem_state);
memcg_id = memcg_alloc_cache_id(); memcg_id = memcg_alloc_cache_id();
if (memcg_id < 0) if (memcg_id < 0)
...@@ -3643,7 +3642,6 @@ static int memcg_online_kmem(struct mem_cgroup *memcg) ...@@ -3643,7 +3642,6 @@ static int memcg_online_kmem(struct mem_cgroup *memcg)
static_branch_enable(&memcg_kmem_enabled_key); static_branch_enable(&memcg_kmem_enabled_key);
memcg->kmemcg_id = memcg_id; memcg->kmemcg_id = memcg_id;
memcg->kmem_state = KMEM_ONLINE;
return 0; return 0;
} }
...@@ -3653,11 +3651,9 @@ static void memcg_offline_kmem(struct mem_cgroup *memcg) ...@@ -3653,11 +3651,9 @@ static void memcg_offline_kmem(struct mem_cgroup *memcg)
struct mem_cgroup *parent; struct mem_cgroup *parent;
int kmemcg_id; int kmemcg_id;
if (memcg->kmem_state != KMEM_ONLINE) if (memcg->kmemcg_id == -1)
return; return;
memcg->kmem_state = KMEM_ALLOCATED;
parent = parent_mem_cgroup(memcg); parent = parent_mem_cgroup(memcg);
if (!parent) if (!parent)
parent = root_mem_cgroup; parent = root_mem_cgroup;
...@@ -3676,6 +3672,7 @@ static void memcg_offline_kmem(struct mem_cgroup *memcg) ...@@ -3676,6 +3672,7 @@ static void memcg_offline_kmem(struct mem_cgroup *memcg)
memcg_drain_all_list_lrus(kmemcg_id, parent); memcg_drain_all_list_lrus(kmemcg_id, parent);
memcg_free_cache_id(kmemcg_id); memcg_free_cache_id(kmemcg_id);
memcg->kmemcg_id = -1;
} }
#else #else
static int memcg_online_kmem(struct mem_cgroup *memcg) static int memcg_online_kmem(struct mem_cgroup *memcg)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment