chiark / gitweb /
core: make hybrid cgroup unified mode keep compat /sys/fs/cgroup/elogind hierarchy
authorTejun Heo <htejun@fb.com>
Mon, 21 Nov 2016 19:45:53 +0000 (14:45 -0500)
committerSven Eden <yamakuzure@gmx.net>
Mon, 17 Jul 2017 15:58:35 +0000 (17:58 +0200)
commitf000ad56fe2346cc8391eeb684681e707711b3ce
treec87d454e456ce891cfc3ed25d1adff39d62d2c43
parent2f30582bd3d00ce582d190ddb379e46e0a67f813
core: make hybrid cgroup unified mode keep compat /sys/fs/cgroup/elogind hierarchy

Currently the hybrid mode mounts cgroup v2 on /sys/fs/cgroup instead of the v1
name=elogind hierarchy.  While this works fine for elogind itself, it breaks
tools which expect cgroup v1 hierarchy on /sys/fs/cgroup/elogind.

This patch updates the hybrid mode so that it mounts v2 hierarchy on
/sys/fs/cgroup/unified and keeps v1 "name=elogind" hierarchy on
/sys/fs/cgroup/elogind for compatibility.  elogind itself doesn't depend on the
"name=elogind" hierarchy at all.  All operations take place on the v2 hierarchy
as before but the v1 hierarchy is kept in sync so that any tools which expect
it to be there can keep doing so.  This allows elogind to take advantage of
cgroup v2 process management without requiring other tools to be aware of the
hybrid mode.

The hybrid mode is implemented by mapping the special elogind controller to
/sys/fs/cgroup/unified and making the basic cgroup utility operations -
cg_attach(), cg_create(), cg_rmdir() and cg_trim() - also operate on the
/sys/fs/cgroup/elogind hierarchy whenever the cgroup2 hierarchy is updated.

While a bit messy, this will allow dropping complications from using cgroup v1
for process management a lot sooner than otherwise possible which should make
it a net gain in terms of maintainability.

v2: Fixed !cgns breakage reported by @evverx and renamed the unified mount
    point to /sys/fs/cgroup/unified as suggested by @brauner.

v3: chown the compat hierarchy too on delegation.  Suggested by @evverx.

v4: [zj]
- drop the change to default, full "legacy" is still the default.
Makefile.am
configure.ac
src/basic/cgroup-util.c
src/basic/cgroup-util.h
src/basic/def.h
src/core/mount-setup.c