950-0136-cgroup-Disable-cgroup-memory-by-default.patch 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. From 584bc4a6093ceb9aea07673185ee0084edc8690b 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 136/454] 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 | 30 ++++++++++++++++++++++++++++++
  12. 1 file changed, 30 insertions(+)
  13. --- a/kernel/cgroup/cgroup.c
  14. +++ b/kernel/cgroup/cgroup.c
  15. @@ -5162,6 +5162,8 @@ int __init cgroup_init_early(void)
  16. }
  17. static u16 cgroup_disable_mask __initdata;
  18. +static u16 cgroup_enable_mask __initdata;
  19. +static int __init cgroup_disable(char *str);
  20. /**
  21. * cgroup_init - cgroup initialization
  22. @@ -5200,6 +5202,12 @@ int __init cgroup_init(void)
  23. mutex_unlock(&cgroup_mutex);
  24. + /* Apply an implicit disable... */
  25. + cgroup_disable("memory");
  26. +
  27. + /* ...knowing that an explicit enable will override it. */
  28. + cgroup_disable_mask &= ~cgroup_enable_mask;
  29. +
  30. for_each_subsys(ss, ssid) {
  31. if (ss->early_init) {
  32. struct cgroup_subsys_state *css =
  33. @@ -5583,6 +5591,28 @@ static int __init cgroup_disable(char *s
  34. }
  35. __setup("cgroup_disable=", cgroup_disable);
  36. +static int __init cgroup_enable(char *str)
  37. +{
  38. + struct cgroup_subsys *ss;
  39. + char *token;
  40. + int i;
  41. +
  42. + while ((token = strsep(&str, ",")) != NULL) {
  43. + if (!*token)
  44. + continue;
  45. +
  46. + for_each_subsys(ss, i) {
  47. + if (strcmp(token, ss->name) &&
  48. + strcmp(token, ss->legacy_name))
  49. + continue;
  50. +
  51. + cgroup_enable_mask |= 1 << i;
  52. + }
  53. + }
  54. + return 1;
  55. +}
  56. +__setup("cgroup_enable=", cgroup_enable);
  57. +
  58. /**
  59. * css_tryget_online_from_dir - get corresponding css from a cgroup dentry
  60. * @dentry: directory dentry of interest