bcm27xx: update patches from RPi foundation
[oweals/openwrt.git] / target / linux / bcm27xx / patches-5.4 / 950-0089-cgroup-Disable-cgroup-memory-by-default.patch
1 From 0f95a2f2688ff44dc7080beaa2076741a0bdf510 Mon Sep 17 00:00:00 2001
2 From: Phil Elwell <phil@raspberrypi.org>
3 Date: Mon, 27 Nov 2017 17:14:54 +0000
4 Subject: [PATCH] cgroup: Disable cgroup "memory" by default
5
6 Some Raspberry Pis have limited RAM and most users won't use the
7 cgroup memory support so it is disabled by default. Enable with:
8
9     cgroup_enable=memory
10
11 See: https://github.com/raspberrypi/linux/issues/1950
12
13 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
14 ---
15  kernel/cgroup/cgroup.c | 30 ++++++++++++++++++++++++++++++
16  1 file changed, 30 insertions(+)
17
18 --- a/kernel/cgroup/cgroup.c
19 +++ b/kernel/cgroup/cgroup.c
20 @@ -5720,6 +5720,8 @@ int __init cgroup_init_early(void)
21  }
22  
23  static u16 cgroup_disable_mask __initdata;
24 +static u16 cgroup_enable_mask __initdata;
25 +static int __init cgroup_disable(char *str);
26  
27  /**
28   * cgroup_init - cgroup initialization
29 @@ -5759,6 +5761,12 @@ int __init cgroup_init(void)
30  
31         mutex_unlock(&cgroup_mutex);
32  
33 +       /* Apply an implicit disable... */
34 +       cgroup_disable("memory");
35 +
36 +       /* ...knowing that an explicit enable will override it. */
37 +       cgroup_disable_mask &= ~cgroup_enable_mask;
38 +
39         for_each_subsys(ss, ssid) {
40                 if (ss->early_init) {
41                         struct cgroup_subsys_state *css =
42 @@ -6178,6 +6186,28 @@ static int __init cgroup_disable(char *s
43  }
44  __setup("cgroup_disable=", cgroup_disable);
45  
46 +static int __init cgroup_enable(char *str)
47 +{
48 +       struct cgroup_subsys *ss;
49 +       char *token;
50 +       int i;
51 +
52 +       while ((token = strsep(&str, ",")) != NULL) {
53 +               if (!*token)
54 +                       continue;
55 +
56 +               for_each_subsys(ss, i) {
57 +                       if (strcmp(token, ss->name) &&
58 +                           strcmp(token, ss->legacy_name))
59 +                               continue;
60 +
61 +                       cgroup_enable_mask |= 1 << i;
62 +               }
63 +       }
64 +       return 1;
65 +}
66 +__setup("cgroup_enable=", cgroup_enable);
67 +
68  void __init __weak enable_debug_cgroup(void) { }
69  
70  static int __init enable_cgroup_debug(char *str)