Skip to content

Commit 7be0cdf

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 3519f47 commit 7be0cdf

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
@@ -6081,6 +6081,9 @@ int __init cgroup_init_early(void)
60816081
return 0;
60826082
}
60836083

6084+
static u16 cgroup_enable_mask __initdata;
6085+
static int __init cgroup_disable(char *str);
6086+
60846087
/**
60856088
* cgroup_init - cgroup initialization
60866089
*
@@ -6114,6 +6117,12 @@ int __init cgroup_init(void)
61146117

61156118
cgroup_unlock();
61166119

6120+
/*
6121+
* Apply an implicit disable, knowing that an explicit enable will
6122+
* prevent if from doing anything.
6123+
*/
6124+
cgroup_disable("memory");
6125+
61176126
for_each_subsys(ss, ssid) {
61186127
if (ss->early_init) {
61196128
struct cgroup_subsys_state *css =
@@ -6760,6 +6769,10 @@ static int __init cgroup_disable(char *str)
67606769
strcmp(token, ss->legacy_name))
67616770
continue;
67626771

6772+
/* An explicit cgroup_enable overrides a disable */
6773+
if (cgroup_enable_mask & (1 << i))
6774+
continue;
6775+
67636776
static_branch_disable(cgroup_subsys_enabled_key[i]);
67646777
pr_info("Disabling %s control group subsystem\n",
67656778
ss->name);
@@ -6778,6 +6791,31 @@ static int __init cgroup_disable(char *str)
67786791
}
67796792
__setup("cgroup_disable=", cgroup_disable);
67806793

6794+
static int __init cgroup_enable(char *str)
6795+
{
6796+
struct cgroup_subsys *ss;
6797+
char *token;
6798+
int i;
6799+
6800+
while ((token = strsep(&str, ",")) != NULL) {
6801+
if (!*token)
6802+
continue;
6803+
6804+
for_each_subsys(ss, i) {
6805+
if (strcmp(token, ss->name) &&
6806+
strcmp(token, ss->legacy_name))
6807+
continue;
6808+
6809+
cgroup_enable_mask |= 1 << i;
6810+
static_branch_enable(cgroup_subsys_enabled_key[i]);
6811+
pr_info("Enabling %s control group subsystem\n",
6812+
ss->name);
6813+
}
6814+
}
6815+
return 1;
6816+
}
6817+
__setup("cgroup_enable=", cgroup_enable);
6818+
67816819
void __init __weak enable_debug_cgroup(void) { }
67826820

67836821
static int __init enable_cgroup_debug(char *str)

0 commit comments

Comments
 (0)