Skip to content

Commit aa17192

Browse files
Phil Elwellpopcornmix
Phil Elwell
authored andcommitted
cgroup: Disable cgroup "memory" by default
Some Raspberry Pis have limited RAM and most users won't use the cgroup memory support so it is disabled by default. Enable with: cgroup_enable=memory See: #1950 Signed-off-by: Phil Elwell <[email protected]>
1 parent 1ce9733 commit aa17192

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

kernel/cgroup/cgroup.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6066,6 +6066,9 @@ int __init cgroup_init_early(void)
60666066
return 0;
60676067
}
60686068

6069+
static u16 cgroup_enable_mask __initdata;
6070+
static int __init cgroup_disable(char *str);
6071+
60696072
/**
60706073
* cgroup_init - cgroup initialization
60716074
*
@@ -6099,6 +6102,12 @@ int __init cgroup_init(void)
60996102

61006103
cgroup_unlock();
61016104

6105+
/*
6106+
* Apply an implicit disable, knowing that an explicit enable will
6107+
* prevent if from doing anything.
6108+
*/
6109+
cgroup_disable("memory");
6110+
61026111
for_each_subsys(ss, ssid) {
61036112
if (ss->early_init) {
61046113
struct cgroup_subsys_state *css =
@@ -6741,6 +6750,10 @@ static int __init cgroup_disable(char *str)
67416750
strcmp(token, ss->legacy_name))
67426751
continue;
67436752

6753+
/* An explicit cgroup_enable overrides a disable */
6754+
if (cgroup_enable_mask & (1 << i))
6755+
continue;
6756+
67446757
static_branch_disable(cgroup_subsys_enabled_key[i]);
67456758
pr_info("Disabling %s control group subsystem\n",
67466759
ss->name);
@@ -6759,6 +6772,31 @@ static int __init cgroup_disable(char *str)
67596772
}
67606773
__setup("cgroup_disable=", cgroup_disable);
67616774

6775+
static int __init cgroup_enable(char *str)
6776+
{
6777+
struct cgroup_subsys *ss;
6778+
char *token;
6779+
int i;
6780+
6781+
while ((token = strsep(&str, ",")) != NULL) {
6782+
if (!*token)
6783+
continue;
6784+
6785+
for_each_subsys(ss, i) {
6786+
if (strcmp(token, ss->name) &&
6787+
strcmp(token, ss->legacy_name))
6788+
continue;
6789+
6790+
cgroup_enable_mask |= 1 << i;
6791+
static_branch_enable(cgroup_subsys_enabled_key[i]);
6792+
pr_info("Enabling %s control group subsystem\n",
6793+
ss->name);
6794+
}
6795+
}
6796+
return 1;
6797+
}
6798+
__setup("cgroup_enable=", cgroup_enable);
6799+
67626800
void __init __weak enable_debug_cgroup(void) { }
67636801

67646802
static int __init enable_cgroup_debug(char *str)

0 commit comments

Comments
 (0)