]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Merge pull request #3965 from htejun/systemd-controller-on-unified
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 19 Aug 2016 23:00:25 +0000 (19:00 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 19 Aug 2016 23:58:01 +0000 (19:58 -0400)
1  2 
src/basic/cgroup-util.c
src/basic/cgroup-util.h
src/core/cgroup.c
src/core/manager.c
src/core/service.c
src/core/unit.c

index 25ef8a5c76eb8b3249b6764d8cf15192cf9e3a5d,1ef1de0604e9d0242e30f5ee709edaa888183ac8..9b44c5a7a59492b46122f55ca8d7ea8174e255e4
@@@ -2333,6 -2356,50 +2356,50 @@@ bool cg_is_legacy_wanted(void) 
          return !cg_is_unified_wanted();
  }
  
 -        if (r > 0) {
+ bool cg_is_unified_systemd_controller_wanted(void) {
+         static thread_local int wanted = -1;
+         int r, unified;
+         /* If the unified hierarchy is requested in full, no need to
+          * bother with this. */
+         if (cg_is_unified_wanted())
+                 return 0;
+         /* If the hierarchy is already mounted, then follow whatever
+          * was chosen for it. */
+         unified = cg_unified(SYSTEMD_CGROUP_CONTROLLER);
+         if (unified >= 0)
+                 return unified;
+         /* Otherwise, let's see what the kernel command line has to
+          * say. Since checking that is expensive, let's cache the
+          * result. */
+         if (wanted >= 0)
+                 return wanted;
+         r = get_proc_cmdline_key("systemd.legacy_systemd_cgroup_controller", NULL);
 -        } else {
++        if (r > 0)
+                 wanted = false;
++        else {
+                 _cleanup_free_ char *value = NULL;
+                 r = get_proc_cmdline_key("systemd.legacy_systemd_cgroup_controller=", &value);
+                 if (r < 0)
+                         return true;
+                 if (r == 0)
+                         wanted = true;
+                 else
+                         wanted = parse_boolean(value) <= 0;
+         }
+         return wanted;
+ }
+ bool cg_is_legacy_systemd_controller_wanted(void) {
+         return cg_is_legacy_wanted() && !cg_is_unified_systemd_controller_wanted();
+ }
  int cg_weight_parse(const char *s, uint64_t *ret) {
          uint64_t u;
          int r;
index f1617a16be9534bb0fb93f051515a307484ca008,5d9bee50f52945402e7c342b6273ad70894d547c..1a61c7ad22a5924b0fd61bed86868927c9a882c8
@@@ -112,10 -112,13 +112,17 @@@ static inline bool CGROUP_BLKIO_WEIGHT_
              (x >= CGROUP_BLKIO_WEIGHT_MIN && x <= CGROUP_BLKIO_WEIGHT_MAX);
  }
  
 +/* Default resource limits */
 +#define DEFAULT_TASKS_MAX_PERCENTAGE            15U /* 15% of PIDs, 4915 on default settings */
 +#define DEFAULT_USER_TASKS_MAX_PERCENTAGE       33U /* 33% of PIDs, 10813 on default settings */
 +
+ typedef enum CGroupUnified {
+         CGROUP_UNIFIED_UNKNOWN = -1,
+         CGROUP_UNIFIED_NONE = 0,        /* Both systemd and controllers on legacy */
+         CGROUP_UNIFIED_SYSTEMD = 1,     /* Only systemd on unified */
+         CGROUP_UNIFIED_ALL = 2,         /* Both systemd and controllers on unified */
+ } CGroupUnified;
  /*
   * General rules:
   *
Simple merge
Simple merge
Simple merge
diff --cc src/core/unit.c
Simple merge