Package: linux / 3.16.56-1+deb8u1

features/all/cgroups-Allow-memory-cgroup-support-to-be-included-b.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
From: Ben Hutchings <ben@decadent.org.uk>
Date: Sun, 30 May 2010 22:43:38 +0100
Subject: cgroups: Allow memory cgroup support to be included but disabled
Forwarded: no

Memory cgroup support has some run-time overhead, so it's useful to
include it in a distribution kernel without enabling it by default.
Add a kernel config option to disable it by default and a kernel
parameter 'cgroup_enable' as the opposite to 'cgroup_disable'.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
[Bastian Blank: Rename CGROUP_MEM_RES_CTLR_DISABLED to MEMCG_DISABLED]
---
 Documentation/kernel-parameters.txt |    4 ++--
 init/Kconfig                        |    8 ++++++++
 kernel/cgroup.c                     |   20 ++++++++++++++++----
 mm/memcontrol.c                     |    3 +++
 4 files changed, 29 insertions(+), 6 deletions(-)

--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -569,8 +569,8 @@ bytes respectively. Such letter suffixes
 	ccw_timeout_log [S390]
 			See Documentation/s390/CommonIO for details.
 
-	cgroup_disable= [KNL] Disable a particular controller
-			Format: {name of the controller(s) to disable}
+	cgroup_disable= [KNL] Disable/enable a particular controller
+	cgroup_enable=	Format: {name of the controller(s) to disable/enable}
 			The effects of cgroup_disable=foo are:
 			- foo isn't auto-mounted if you mount all cgroups in
 			  a single hierarchy
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -960,6 +960,14 @@ config MEMCG
 	  disable memory resource controller and you can avoid overheads.
 	  (and lose benefits of memory resource controller)
 
+config MEMCG_DISABLED
+	bool "Memory Resource Controller disabled by default"
+	depends on MEMCG
+	default n
+	help
+	  Disable the memory group resource controller unless explicitly
+	  enabled using the kernel parameter "cgroup_enable=memory".
+
 config MEMCG_SWAP
 	bool "Memory Resource Controller Swap Extension"
 	depends on MEMCG && SWAP
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -5182,7 +5182,7 @@ static void cgroup_release_agent(struct
 	mutex_unlock(&cgroup_mutex);
 }
 
-static int __init cgroup_disable(char *str)
+static int __init cgroup_set_disabled(char *str, int value)
 {
 	struct cgroup_subsys *ss;
 	char *token;
@@ -5194,17 +5194,29 @@ static int __init cgroup_disable(char *s
 
 		for_each_subsys(ss, i) {
 			if (!strcmp(token, ss->name)) {
-				ss->disabled = 1;
-				printk(KERN_INFO "Disabling %s control group"
-					" subsystem\n", ss->name);
+				ss->disabled = value;
+				printk(KERN_INFO
+				       "%sabling %s control group subsystem\n",
+				       value ? "Dis" : "En", ss->name);
 				break;
 			}
 		}
 	}
 	return 1;
 }
+
+static int __init cgroup_disable(char *str)
+{
+	return cgroup_set_disabled(str, 1);
+}
 __setup("cgroup_disable=", cgroup_disable);
 
+static int __init cgroup_enable(char *str)
+{
+	return cgroup_set_disabled(str, 0);
+}
+__setup("cgroup_enable=", cgroup_enable);
+
 /**
  * css_tryget_online_from_dir - get corresponding css from a cgroup dentry
  * @dentry: directory dentry of interest
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -7015,6 +7015,9 @@ static void mem_cgroup_bind(struct cgrou
 }
 
 struct cgroup_subsys memory_cgrp_subsys = {
+#ifdef CONFIG_MEMCG_DISABLED
+	.disabled = 1,
+#endif
 	.css_alloc = mem_cgroup_css_alloc,
 	.css_online = mem_cgroup_css_online,
 	.css_offline = mem_cgroup_css_offline,