diff options
author | Johannes Weiner <hannes@cmpxchg.org> | 2016-01-20 15:02:29 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-01-20 17:09:18 -0800 |
commit | 3893e302f6a377c4ef0f077f190bf760bf84e0be (patch) | |
tree | 175b76f8c6b0ca1d243420a192e796a9665da15d /mm | |
parent | 8e0a891213fbddcec231c9d1d7577c320c77a25a (diff) |
mm: memcontrol: separate kmem code from legacy tcp accounting code
The cgroup2 memory controller will include important in-kernel memory
consumers per default, including socket memory, but it will no longer
carry the historic tcp control interface.
Separate the kmem state init from the tcp control interface init in
preparation for that.
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Tejun Heo <tj@kernel.org>
Acked-by: Vladimir Davydov <vdavydov@virtuozzo.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/memcontrol.c | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 3dd9fe35fe62..7f8219b58e0c 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -2946,17 +2946,6 @@ static int memcg_propagate_kmem(struct mem_cgroup *memcg) return ret; } -static int memcg_init_kmem(struct mem_cgroup *memcg) -{ - int ret; - - ret = memcg_propagate_kmem(memcg); - if (ret) - return ret; - - return tcp_init_cgroup(memcg); -} - static void memcg_offline_kmem(struct mem_cgroup *memcg) { struct cgroup_subsys_state *css; @@ -3009,7 +2998,6 @@ static void memcg_free_kmem(struct mem_cgroup *memcg) static_branch_dec(&memcg_kmem_enabled_key); WARN_ON(page_counter_read(&memcg->kmem)); } - tcp_destroy_cgroup(memcg); } #else static int memcg_update_kmem_limit(struct mem_cgroup *memcg, @@ -3017,16 +3005,9 @@ static int memcg_update_kmem_limit(struct mem_cgroup *memcg, { return -EINVAL; } -static int memcg_init_kmem(struct mem_cgroup *memcg) -{ - return 0; -} static void memcg_offline_kmem(struct mem_cgroup *memcg) { } -static void memcg_free_kmem(struct mem_cgroup *memcg) -{ -} #endif /* CONFIG_MEMCG_KMEM */ /* @@ -4263,9 +4244,14 @@ mem_cgroup_css_online(struct cgroup_subsys_state *css) } mutex_unlock(&memcg_create_mutex); - ret = memcg_init_kmem(memcg); +#ifdef CONFIG_MEMCG_KMEM + ret = memcg_propagate_kmem(memcg); if (ret) return ret; + ret = tcp_init_cgroup(memcg); + if (ret) + return ret; +#endif #ifdef CONFIG_INET if (cgroup_subsys_on_dfl(memory_cgrp_subsys) && !cgroup_memory_nosocket) @@ -4317,11 +4303,16 @@ static void mem_cgroup_css_free(struct cgroup_subsys_state *css) { struct mem_cgroup *memcg = mem_cgroup_from_css(css); - memcg_free_kmem(memcg); #ifdef CONFIG_INET if (cgroup_subsys_on_dfl(memory_cgrp_subsys) && !cgroup_memory_nosocket) static_branch_dec(&memcg_sockets_enabled_key); #endif + +#ifdef CONFIG_MEMCG_KMEM + memcg_free_kmem(memcg); + tcp_destroy_cgroup(memcg); +#endif + __mem_cgroup_free(memcg); } |