chiark / gitweb /
Fix cgroup directory mounting:
authorSven Eden <yamakuzure@gmx.net>
Wed, 20 Jun 2018 17:13:05 +0000 (19:13 +0200)
committerSven Eden <yamakuzure@gmx.net>
Fri, 29 Jun 2018 05:12:51 +0000 (07:12 +0200)
A little misunderstanding has been fixed, and elogind now mounts the following
directories, if (and only if) it has to act as its own cgroups controller.

  * -Ddefault-hierarchy=legacy  : /sys/fs/cgroup         as tmpfs
                                  /sys/fs/cgroup/elogind as cgroup

  * -Ddefault-hierarchy=hybrid  : The same as with 'legacy', plus
                                  /sys/fs/cgroup/unified as cgroup2

  * -Ddefault-hierarchy=unified : /sys/fs/cgroup2        as cgroup2

meson_options.txt
src/basic/cgroup-util.c
src/core/mount-setup.c

index 0fa3f1896ab38f36d6be9baee2159376cf9a9f9e..84100b6298985d755277c4aa6cac4c3b8a54b27f 100644 (file)
@@ -189,9 +189,10 @@ option('default-hierarchy', type : 'combo',
 #        description : 'time epoch for time clients')
 #else
        description : '''Wanted cgroup hierarchy if elogind has to be a cgroup controller:
-                "legacy"  assumes cgroups version 1 mounted on /sys/fs/cgroup
-                "hybrid"  assumes cgroups version 2 mounted on /sys/fs/cgroup/unified and
-                                  cgroups version 1 mounted on /sys/fs/cgroup.
+                "legacy"  assumes tmpfs mounted on /sys/fs/cgroup and cgroup on its
+                                  subfolders.
+                "hybrid"  assumes cgroups version 2 mounted on /sys/fs/cgroup/unified.
+                                  /sys/fs/cgroup is legacy, then.
                 "unified" assumes cgroups version 2 on /sys/fs/cgroup''')
 option('cgroup-controller', type : 'string',
        description : 'Name of the cgroup controller to use')
index fa92750439f190c9d050da229f68cc4ee81d4f70..4fc542cc894350a857ea2e18814ab0c2d410ff38 100644 (file)
@@ -2740,8 +2740,10 @@ int cg_enable_everywhere(CGroupMask supported, CGroupMask mask, const char *p) {
 
 bool cg_is_unified_wanted(void) {
         static thread_local int wanted = -1;
+#if 0 /// UNNEEDED by elogind
         int r;
         bool b;
+#endif // 0
         const bool is_default = DEFAULT_HIERARCHY == CGROUP_UNIFIED_ALL;
 
         /* If we have a cached value, return that. */
@@ -2757,9 +2759,11 @@ bool cg_is_unified_wanted(void) {
         /* Otherwise, let's see what the kernel command line has to say.
          * Since checking is expensive, cache a non-error result. */
         r = proc_cmdline_get_bool("systemd.unified_cgroup_hierarchy", &b);
-#endif // 0
 
         return (wanted = r > 0 ? b : is_default);
+#else
+        return is_default;
+#endif // 0
 }
 
 bool cg_is_legacy_wanted(void) {
@@ -2781,8 +2785,10 @@ bool cg_is_legacy_wanted(void) {
 
 bool cg_is_hybrid_wanted(void) {
         static thread_local int wanted = -1;
+#if 0 /// UNNEEDED by elogind
         int r;
         bool b;
+#endif // 0
         const bool is_default = DEFAULT_HIERARCHY >= CGROUP_UNIFIED_SYSTEMD;
         /* We default to true if the default is "hybrid", obviously,
          * but also when the default is "unified", because if we get
@@ -2802,11 +2808,13 @@ bool cg_is_hybrid_wanted(void) {
         /* Otherwise, let's see what the kernel command line has to say.
          * Since checking is expensive, cache a non-error result. */
         r = proc_cmdline_get_bool("systemd.legacy_systemd_cgroup_controller", &b);
-#endif // 0
 
         /* The meaning of the kernel option is reversed wrt. to the return value
          * of this function, hence the negation. */
         return (wanted = r > 0 ? !b : is_default);
+#else
+        return is_default;
+#endif // 0
 }
 
 #if 0 /// UNNEEDED by elogind
index 0b41e26e6fa3ed7f48ab807dafb522ac2bad31f8..f08abb640ac9e93980aabf9b7b6a6ac8baea6a5b 100644 (file)
@@ -103,11 +103,11 @@ static const MountPoint mount_table[] = {
 #endif
         { "tmpfs",       "/run",                      "tmpfs",      "mode=755",                MS_NOSUID|MS_NODEV|MS_STRICTATIME,
           NULL,          MNT_FATAL|MNT_IN_CONTAINER },
+#endif // 0
         { "cgroup2",     "/sys/fs/cgroup",            "cgroup2",    "nsdelegate",              MS_NOSUID|MS_NOEXEC|MS_NODEV,
           cg_is_unified_wanted, MNT_IN_CONTAINER|MNT_CHECK_WRITABLE },
         { "cgroup2",     "/sys/fs/cgroup",            "cgroup2",    NULL,                      MS_NOSUID|MS_NOEXEC|MS_NODEV,
           cg_is_unified_wanted, MNT_IN_CONTAINER|MNT_CHECK_WRITABLE },
-#endif // 0
         { "tmpfs",       "/sys/fs/cgroup",            "tmpfs",      "mode=755",                MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_STRICTATIME,
           cg_is_legacy_wanted, MNT_FATAL|MNT_IN_CONTAINER },
         { "cgroup2",     "/sys/fs/cgroup/unified",    "cgroup2",    "nsdelegate",              MS_NOSUID|MS_NOEXEC|MS_NODEV,
@@ -130,7 +130,7 @@ static const MountPoint mount_table[] = {
 #else
         { "cgroup",      "/sys/fs/cgroup/elogind",    "cgroup",     "none,name=elogind,release_agent="SYSTEMD_CGROUP_AGENT_PATH",xattr", MS_NOSUID|MS_NOEXEC|MS_NODEV,
           cg_is_legacy_wanted, MNT_IN_CONTAINER  },
-        { "cgroup",      "/sys/fs/cgroup/elogind",    "cgroup",     "none,name=elogind,release_agent="SYSTEMD_CGROUP_AGENT_PATH,       MS_NOSUID|MS_NOEXEC|MS_NODEV,
+        { "cgroup",      "/sys/fs/cgroup/eloignd",    "cgroup",     "none,name=elogind,release_agent="SYSTEMD_CGROUP_AGENT_PATH,         MS_NOSUID|MS_NOEXEC|MS_NODEV,
           cg_is_legacy_wanted, MNT_FATAL|MNT_IN_CONTAINER },
 #endif // 0
 };