aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Weiner <hannes@cmpxchg.org>2016-01-20 18:02:41 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2016-01-20 20:09:18 -0500
commit489c2a20a414351fe0813a727c34600c0f7292ae (patch)
tree3e1417700db70366ac8d9a73b38958c3904732db
parent04823c833b3eaef7816e28e3727124394f6bb3c3 (diff)
mm: memcontrol: introduce CONFIG_MEMCG_LEGACY_KMEM
Let the user know that CONFIG_MEMCG_KMEM does not apply to the cgroup2 interface. This also makes legacy-only code sections stand out better. [arnd@arndb.de: mm: memcontrol: only manage socket pressure for CONFIG_INET] Signed-off-by: Johannes Weiner <hannes@cmpxchg.org> Cc: Michal Hocko <mhocko@suse.cz> Cc: Tejun Heo <tj@kernel.org> Acked-by: Vladimir Davydov <vdavydov@virtuozzo.com> Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--include/linux/memcontrol.h4
-rw-r--r--init/Kconfig10
-rw-r--r--mm/memcontrol.c18
-rw-r--r--mm/vmpressure.c2
-rw-r--r--net/ipv4/Makefile2
5 files changed, 23 insertions, 13 deletions
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index a87704e3668e..2bb14d021cd0 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -233,7 +233,7 @@ struct mem_cgroup {
233 */ 233 */
234 struct mem_cgroup_stat_cpu __percpu *stat; 234 struct mem_cgroup_stat_cpu __percpu *stat;
235 235
236#if defined(CONFIG_MEMCG_KMEM) && defined(CONFIG_INET) 236#if defined(CONFIG_MEMCG_LEGACY_KMEM) && defined(CONFIG_INET)
237 struct cg_proto tcp_mem; 237 struct cg_proto tcp_mem;
238#endif 238#endif
239#ifndef CONFIG_SLOB 239#ifndef CONFIG_SLOB
@@ -717,7 +717,7 @@ extern struct static_key_false memcg_sockets_enabled_key;
717#define mem_cgroup_sockets_enabled static_branch_unlikely(&memcg_sockets_enabled_key) 717#define mem_cgroup_sockets_enabled static_branch_unlikely(&memcg_sockets_enabled_key)
718static inline bool mem_cgroup_under_socket_pressure(struct mem_cgroup *memcg) 718static inline bool mem_cgroup_under_socket_pressure(struct mem_cgroup *memcg)
719{ 719{
720#ifdef CONFIG_MEMCG_KMEM 720#ifdef CONFIG_MEMCG_LEGACY_KMEM
721 if (memcg->tcp_mem.memory_pressure) 721 if (memcg->tcp_mem.memory_pressure)
722 return true; 722 return true;
723#endif 723#endif
diff --git a/init/Kconfig b/init/Kconfig
index 5b86082fa238..a0a15cec8daf 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -964,10 +964,13 @@ config MEMCG_SWAP_ENABLED
964 For those who want to have the feature enabled by default should 964 For those who want to have the feature enabled by default should
965 select this option (if, for some reason, they need to disable it 965 select this option (if, for some reason, they need to disable it
966 then swapaccount=0 does the trick). 966 then swapaccount=0 does the trick).
967config MEMCG_LEGACY_KMEM
968 bool
967config MEMCG_KMEM 969config MEMCG_KMEM
968 bool "Memory Resource Controller Kernel Memory accounting" 970 bool "Legacy Memory Resource Controller Kernel Memory accounting"
969 depends on MEMCG 971 depends on MEMCG
970 depends on SLUB || SLAB 972 depends on SLUB || SLAB
973 select MEMCG_LEGACY_KMEM
971 help 974 help
972 The Kernel Memory extension for Memory Resource Controller can limit 975 The Kernel Memory extension for Memory Resource Controller can limit
973 the amount of memory used by kernel objects in the system. Those are 976 the amount of memory used by kernel objects in the system. Those are
@@ -1071,6 +1074,11 @@ config CGROUP_FREEZER
1071 Provides a way to freeze and unfreeze all tasks in a 1074 Provides a way to freeze and unfreeze all tasks in a
1072 cgroup. 1075 cgroup.
1073 1076
1077 This option affects the ORIGINAL cgroup interface. The cgroup2 memory
1078 controller includes important in-kernel memory consumers per default.
1079
1080 If you're using cgroup2, say N.
1081
1074config CGROUP_HUGETLB 1082config CGROUP_HUGETLB
1075 bool "HugeTLB controller" 1083 bool "HugeTLB controller"
1076 depends on HUGETLB_PAGE 1084 depends on HUGETLB_PAGE
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 2239e6dd4d4c..92e8ab67b6df 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -3001,7 +3001,7 @@ static void memcg_free_kmem(struct mem_cgroup *memcg)
3001} 3001}
3002#endif /* !CONFIG_SLOB */ 3002#endif /* !CONFIG_SLOB */
3003 3003
3004#ifdef CONFIG_MEMCG_KMEM 3004#ifdef CONFIG_MEMCG_LEGACY_KMEM
3005static int memcg_update_kmem_limit(struct mem_cgroup *memcg, 3005static int memcg_update_kmem_limit(struct mem_cgroup *memcg,
3006 unsigned long limit) 3006 unsigned long limit)
3007{ 3007{
@@ -3025,7 +3025,7 @@ static int memcg_update_kmem_limit(struct mem_cgroup *memcg,
3025{ 3025{
3026 return -EINVAL; 3026 return -EINVAL;
3027} 3027}
3028#endif /* CONFIG_MEMCG_KMEM */ 3028#endif /* CONFIG_MEMCG_LEGACY_KMEM */
3029 3029
3030 3030
3031/* 3031/*
@@ -4039,7 +4039,7 @@ static struct cftype mem_cgroup_legacy_files[] = {
4039 .seq_show = memcg_numa_stat_show, 4039 .seq_show = memcg_numa_stat_show,
4040 }, 4040 },
4041#endif 4041#endif
4042#ifdef CONFIG_MEMCG_KMEM 4042#ifdef CONFIG_MEMCG_LEGACY_KMEM
4043 { 4043 {
4044 .name = "kmem.limit_in_bytes", 4044 .name = "kmem.limit_in_bytes",
4045 .private = MEMFILE_PRIVATE(_KMEM, RES_LIMIT), 4045 .private = MEMFILE_PRIVATE(_KMEM, RES_LIMIT),
@@ -4266,13 +4266,13 @@ mem_cgroup_css_online(struct cgroup_subsys_state *css)
4266 if (ret) 4266 if (ret)
4267 return ret; 4267 return ret;
4268 4268
4269#ifdef CONFIG_MEMCG_KMEM 4269#ifdef CONFIG_INET
4270#ifdef CONFIG_MEMCG_LEGACY_KMEM
4270 ret = tcp_init_cgroup(memcg); 4271 ret = tcp_init_cgroup(memcg);
4271 if (ret) 4272 if (ret)
4272 return ret; 4273 return ret;
4273#endif 4274#endif
4274 4275
4275#ifdef CONFIG_INET
4276 if (cgroup_subsys_on_dfl(memory_cgrp_subsys) && !cgroup_memory_nosocket) 4276 if (cgroup_subsys_on_dfl(memory_cgrp_subsys) && !cgroup_memory_nosocket)
4277 static_branch_inc(&memcg_sockets_enabled_key); 4277 static_branch_inc(&memcg_sockets_enabled_key);
4278#endif 4278#endif
@@ -4329,7 +4329,7 @@ static void mem_cgroup_css_free(struct cgroup_subsys_state *css)
4329 4329
4330 memcg_free_kmem(memcg); 4330 memcg_free_kmem(memcg);
4331 4331
4332#ifdef CONFIG_MEMCG_KMEM 4332#if defined(CONFIG_MEMCG_LEGACY_KMEM) && defined(CONFIG_INET)
4333 tcp_destroy_cgroup(memcg); 4333 tcp_destroy_cgroup(memcg);
4334#endif 4334#endif
4335 4335
@@ -5558,7 +5558,7 @@ void sock_update_memcg(struct sock *sk)
5558 memcg = mem_cgroup_from_task(current); 5558 memcg = mem_cgroup_from_task(current);
5559 if (memcg == root_mem_cgroup) 5559 if (memcg == root_mem_cgroup)
5560 goto out; 5560 goto out;
5561#ifdef CONFIG_MEMCG_KMEM 5561#ifdef CONFIG_MEMCG_LEGACY_KMEM
5562 if (!cgroup_subsys_on_dfl(memory_cgrp_subsys) && !memcg->tcp_mem.active) 5562 if (!cgroup_subsys_on_dfl(memory_cgrp_subsys) && !memcg->tcp_mem.active)
5563 goto out; 5563 goto out;
5564#endif 5564#endif
@@ -5587,7 +5587,7 @@ bool mem_cgroup_charge_skmem(struct mem_cgroup *memcg, unsigned int nr_pages)
5587{ 5587{
5588 gfp_t gfp_mask = GFP_KERNEL; 5588 gfp_t gfp_mask = GFP_KERNEL;
5589 5589
5590#ifdef CONFIG_MEMCG_KMEM 5590#ifdef CONFIG_MEMCG_LEGACY_KMEM
5591 if (!cgroup_subsys_on_dfl(memory_cgrp_subsys)) { 5591 if (!cgroup_subsys_on_dfl(memory_cgrp_subsys)) {
5592 struct page_counter *counter; 5592 struct page_counter *counter;
5593 5593
@@ -5619,7 +5619,7 @@ bool mem_cgroup_charge_skmem(struct mem_cgroup *memcg, unsigned int nr_pages)
5619 */ 5619 */
5620void mem_cgroup_uncharge_skmem(struct mem_cgroup *memcg, unsigned int nr_pages) 5620void mem_cgroup_uncharge_skmem(struct mem_cgroup *memcg, unsigned int nr_pages)
5621{ 5621{
5622#ifdef CONFIG_MEMCG_KMEM 5622#ifdef CONFIG_MEMCG_LEGACY_KMEM
5623 if (!cgroup_subsys_on_dfl(memory_cgrp_subsys)) { 5623 if (!cgroup_subsys_on_dfl(memory_cgrp_subsys)) {
5624 page_counter_uncharge(&memcg->tcp_mem.memory_allocated, 5624 page_counter_uncharge(&memcg->tcp_mem.memory_allocated,
5625 nr_pages); 5625 nr_pages);
diff --git a/mm/vmpressure.c b/mm/vmpressure.c
index 9a6c0704211c..89b1d441af4b 100644
--- a/mm/vmpressure.c
+++ b/mm/vmpressure.c
@@ -275,6 +275,7 @@ void vmpressure(gfp_t gfp, struct mem_cgroup *memcg, bool tree,
275 275
276 level = vmpressure_calc_level(scanned, reclaimed); 276 level = vmpressure_calc_level(scanned, reclaimed);
277 277
278#ifdef CONFIG_INET
278 if (level > VMPRESSURE_LOW) { 279 if (level > VMPRESSURE_LOW) {
279 /* 280 /*
280 * Let the socket buffer allocator know that 281 * Let the socket buffer allocator know that
@@ -286,6 +287,7 @@ void vmpressure(gfp_t gfp, struct mem_cgroup *memcg, bool tree,
286 */ 287 */
287 memcg->socket_pressure = jiffies + HZ; 288 memcg->socket_pressure = jiffies + HZ;
288 } 289 }
290#endif
289 } 291 }
290} 292}
291 293
diff --git a/net/ipv4/Makefile b/net/ipv4/Makefile
index c29809f765dc..bee5055832a1 100644
--- a/net/ipv4/Makefile
+++ b/net/ipv4/Makefile
@@ -56,7 +56,7 @@ obj-$(CONFIG_TCP_CONG_SCALABLE) += tcp_scalable.o
56obj-$(CONFIG_TCP_CONG_LP) += tcp_lp.o 56obj-$(CONFIG_TCP_CONG_LP) += tcp_lp.o
57obj-$(CONFIG_TCP_CONG_YEAH) += tcp_yeah.o 57obj-$(CONFIG_TCP_CONG_YEAH) += tcp_yeah.o
58obj-$(CONFIG_TCP_CONG_ILLINOIS) += tcp_illinois.o 58obj-$(CONFIG_TCP_CONG_ILLINOIS) += tcp_illinois.o
59obj-$(CONFIG_MEMCG_KMEM) += tcp_memcontrol.o 59obj-$(CONFIG_MEMCG_LEGACY_KMEM) += tcp_memcontrol.o
60obj-$(CONFIG_NETLABEL) += cipso_ipv4.o 60obj-$(CONFIG_NETLABEL) += cipso_ipv4.o
61 61
62obj-$(CONFIG_XFRM) += xfrm4_policy.o xfrm4_state.o xfrm4_input.o \ 62obj-$(CONFIG_XFRM) += xfrm4_policy.o xfrm4_state.o xfrm4_input.o \