cgroup: Fix automatic disabling of cgroup "memory"
authorPhil Elwell <phil@raspberrypi.org>
Mon, 27 Nov 2017 17:14:54 +0000 (17:14 +0000)
committerRaspbian kernel package updater <root@raspbian.org>
Thu, 15 Feb 2018 17:41:08 +0000 (17:41 +0000)
Some Raspberry Pis have limited RAM and most users won't use the
cgroup memory support so it is disabled by default. The previous
implementation relied on the memory cgroup being encountered first,
which is not guaranteed to be the case. Change the implementation
to be registration-order-agnostic.

See: https://github.com/raspberrypi/issues/1950

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
kernel/cgroup.c

index 2650df194b5d0bb39bb92c295d93f691b00faffb..49b0ca043a65b2add87a85fbe7b81e85852c8b62 100644 (file)
@@ -5637,7 +5637,9 @@ int __init cgroup_init_early(void)
        return 0;
 }
 
-static u16 cgroup_disable_mask __initdata = 1<<0;
+static u16 cgroup_disable_mask __initdata;
+static u16 cgroup_enable_mask __initdata;
+static int __init cgroup_disable(char *str);
 
 /**
  * cgroup_init - cgroup initialization
@@ -5676,6 +5678,12 @@ int __init cgroup_init(void)
 
        mutex_unlock(&cgroup_mutex);
 
+       /* Apply an implicit disable... */
+       cgroup_disable("memory");
+
+       /* ...knowing that an explicit enable will override it. */
+       cgroup_disable_mask &= ~cgroup_enable_mask;
+
        for_each_subsys(ss, ssid) {
                if (ss->early_init) {
                        struct cgroup_subsys_state *css =
@@ -6193,7 +6201,7 @@ static int __init cgroup_enable(char *str)
                            strcmp(token, ss->legacy_name))
                                continue;
 
-                       cgroup_disable_mask &= ~(1 << i);
+                       cgroup_enable_mask |= 1 << i;
                }
        }
        return 1;