950-0035-cgroup-Disable-cgroup-memory-by-default.patch 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. From e2494e8c48c510ccefc889393f5d776b5e3824ac Mon Sep 17 00:00:00 2001
  2. From: Phil Elwell <[email protected]>
  3. Date: Mon, 27 Nov 2017 17:14:54 +0000
  4. Subject: [PATCH] cgroup: Disable cgroup "memory" by default
  5. Some Raspberry Pis have limited RAM and most users won't use the
  6. cgroup memory support so it is disabled by default. Enable with:
  7. cgroup_enable=memory
  8. See: https://github.com/raspberrypi/linux/issues/1950
  9. Signed-off-by: Phil Elwell <[email protected]>
  10. ---
  11. kernel/cgroup/cgroup.c | 38 ++++++++++++++++++++++++++++++++++++++
  12. 1 file changed, 38 insertions(+)
  13. --- a/kernel/cgroup/cgroup.c
  14. +++ b/kernel/cgroup/cgroup.c
  15. @@ -5875,6 +5875,9 @@ int __init cgroup_init_early(void)
  16. return 0;
  17. }
  18. +static u16 cgroup_enable_mask __initdata;
  19. +static int __init cgroup_disable(char *str);
  20. +
  21. /**
  22. * cgroup_init - cgroup initialization
  23. *
  24. @@ -5913,6 +5916,12 @@ int __init cgroup_init(void)
  25. mutex_unlock(&cgroup_mutex);
  26. + /*
  27. + * Apply an implicit disable, knowing that an explicit enable will
  28. + * prevent if from doing anything.
  29. + */
  30. + cgroup_disable("memory");
  31. +
  32. for_each_subsys(ss, ssid) {
  33. if (ss->early_init) {
  34. struct cgroup_subsys_state *css =
  35. @@ -6503,6 +6512,10 @@ static int __init cgroup_disable(char *s
  36. strcmp(token, ss->legacy_name))
  37. continue;
  38. + /* An explicit cgroup_enable overrides a disable */
  39. + if (cgroup_enable_mask & (1 << i))
  40. + continue;
  41. +
  42. static_branch_disable(cgroup_subsys_enabled_key[i]);
  43. pr_info("Disabling %s control group subsystem\n",
  44. ss->name);
  45. @@ -6521,6 +6534,31 @@ static int __init cgroup_disable(char *s
  46. }
  47. __setup("cgroup_disable=", cgroup_disable);
  48. +static int __init cgroup_enable(char *str)
  49. +{
  50. + struct cgroup_subsys *ss;
  51. + char *token;
  52. + int i;
  53. +
  54. + while ((token = strsep(&str, ",")) != NULL) {
  55. + if (!*token)
  56. + continue;
  57. +
  58. + for_each_subsys(ss, i) {
  59. + if (strcmp(token, ss->name) &&
  60. + strcmp(token, ss->legacy_name))
  61. + continue;
  62. +
  63. + cgroup_enable_mask |= 1 << i;
  64. + static_branch_enable(cgroup_subsys_enabled_key[i]);
  65. + pr_info("Enabling %s control group subsystem\n",
  66. + ss->name);
  67. + }
  68. + }
  69. + return 1;
  70. +}
  71. +__setup("cgroup_enable=", cgroup_enable);
  72. +
  73. void __init __weak enable_debug_cgroup(void) { }
  74. static int __init enable_cgroup_debug(char *str)