Skip to content

Commit e80216d

Browse files
Muchun Songtorvalds
authored andcommitted
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/[email protected] Signed-off-by: Muchun Song <[email protected]> Acked-by: Roman Gushchin <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Shakeel Butt <[email protected]> Cc: Matthew Wilcox (Oracle) <[email protected]> Cc: Johannes Weiner <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 6426886 commit e80216d

File tree

2 files changed

+2
-12
lines changed

2 files changed

+2
-12
lines changed

include/linux/memcontrol.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,6 @@ struct mem_cgroup_thresholds {
180180
struct mem_cgroup_threshold_ary *spare;
181181
};
182182

183-
enum memcg_kmem_state {
184-
KMEM_NONE,
185-
KMEM_ALLOCATED,
186-
KMEM_ONLINE,
187-
};
188-
189183
#if defined(CONFIG_SMP)
190184
struct memcg_padding {
191185
char x[0];
@@ -318,7 +312,6 @@ struct mem_cgroup {
318312

319313
#ifdef CONFIG_MEMCG_KMEM
320314
int kmemcg_id;
321-
enum memcg_kmem_state kmem_state;
322315
struct obj_cgroup __rcu *objcg;
323316
struct list_head objcg_list; /* list of inherited objcgs */
324317
#endif

mm/memcontrol.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3626,7 +3626,6 @@ static int memcg_online_kmem(struct mem_cgroup *memcg)
36263626
return 0;
36273627

36283628
BUG_ON(memcg->kmemcg_id >= 0);
3629-
BUG_ON(memcg->kmem_state);
36303629

36313630
memcg_id = memcg_alloc_cache_id();
36323631
if (memcg_id < 0)
@@ -3643,7 +3642,6 @@ static int memcg_online_kmem(struct mem_cgroup *memcg)
36433642
static_branch_enable(&memcg_kmem_enabled_key);
36443643

36453644
memcg->kmemcg_id = memcg_id;
3646-
memcg->kmem_state = KMEM_ONLINE;
36473645

36483646
return 0;
36493647
}
@@ -3653,11 +3651,9 @@ static void memcg_offline_kmem(struct mem_cgroup *memcg)
36533651
struct mem_cgroup *parent;
36543652
int kmemcg_id;
36553653

3656-
if (memcg->kmem_state != KMEM_ONLINE)
3654+
if (memcg->kmemcg_id == -1)
36573655
return;
36583656

3659-
memcg->kmem_state = KMEM_ALLOCATED;
3660-
36613657
parent = parent_mem_cgroup(memcg);
36623658
if (!parent)
36633659
parent = root_mem_cgroup;
@@ -3676,6 +3672,7 @@ static void memcg_offline_kmem(struct mem_cgroup *memcg)
36763672
memcg_drain_all_list_lrus(kmemcg_id, parent);
36773673

36783674
memcg_free_cache_id(kmemcg_id);
3675+
memcg->kmemcg_id = -1;
36793676
}
36803677
#else
36813678
static int memcg_online_kmem(struct mem_cgroup *memcg)

0 commit comments

Comments
 (0)