Systemd/src/core
Lennart Poettering efdb02375b core: unified cgroup hierarchy support
This patch set adds full support the new unified cgroup hierarchy logic
of modern kernels.

A new kernel command line option "systemd.unified_cgroup_hierarchy=1" is
added. If specified the unified hierarchy is mounted to /sys/fs/cgroup
instead of a tmpfs. No further hierarchies are mounted. The kernel
command line option defaults to off. We can turn it on by default as
soon as the kernel's APIs regarding this are stabilized (but even then
downstream distros might want to turn this off, as this will break any
tools that access cgroupfs directly).

It is possibly to choose for each boot individually whether the unified
or the legacy hierarchy is used. nspawn will by default provide the
legacy hierarchy to containers if the host is using it, and the unified
otherwise. However it is possible to run containers with the unified
hierarchy on a legacy host and vice versa, by setting the
$UNIFIED_CGROUP_HIERARCHY environment variable for nspawn to 1 or 0,
respectively.

The unified hierarchy provides reliable cgroup empty notifications for
the first time, via inotify. To make use of this we maintain one
manager-wide inotify fd, and each cgroup to it.

This patch also removes cg_delete() which is unused now.

On kernel 4.2 only the "memory" controller is compatible with the
unified hierarchy, hence that's the only controller systemd exposes when
booted in unified heirarchy mode.

This introduces a new enum for enumerating supported controllers, plus a
related enum for the mask bits mapping to it. The core is changed to
make use of this everywhere.

This moves PID 1 into a new "init.scope" implicit scope unit in the root
slice. This is necessary since on the unified hierarchy cgroups may
either contain subgroups or processes but not both. PID 1 hence has to
move out of the root cgroup (strictly speaking the root cgroup is the
only one where processes and subgroups are still allowed, but in order
to support containers nicey, we move PID 1 into the new scope in all
cases.) This new unit is also used on legacy hierarchy setups. It's
actually pretty useful on all systems, as it can then be used to filter
journal messages coming from PID 1, and so on.

The root slice ("-.slice") is now implicitly created and started (and
does not require a unit file on disk anymore), since
that's where "init.scope" is located and the slice needs to be started
before the scope can.

To check whether we are in unified or legacy hierarchy mode we use
statfs() on /sys/fs/cgroup. If the .f_type field reports tmpfs we are in
legacy mode, if it reports cgroupfs we are in unified mode.

This patch set carefuly makes sure that cgls and cgtop continue to work
as desired.

When invoking nspawn as a service it will implicitly create two
subcgroups in the cgroup it is using, one to move the nspawn process
into, the other to move the actual container processes into. This is
done because of the requirement that cgroups may either contain
processes or other subgroups.
2015-09-01 23:52:27 +02:00
..
.gitignore
audit-fd.c treewide: use log_*_errno whenever %m is in the format string 2014-11-28 19:49:27 +01:00
audit-fd.h
automount.c core: add unit_dbus_interface_from_type() to unit-name.h 2015-08-28 02:10:10 +02:00
automount.h automount: add expire support 2015-04-21 20:23:41 +02:00
bus-endpoint.c bus: sync with kdbus (ABI break) 2015-02-05 16:52:42 +01:00
bus-endpoint.h core: rearrange code so that libsystemd/sd-bus/ does not include header files from core 2014-12-23 19:15:27 +01:00
bus-policy.c sd-bus: when we get ENOTTY on the HELLO ioctl assume incompatible API version 2015-04-30 01:24:48 +02:00
bus-policy.h bus: add missing bus-policy.[ch] 2014-12-23 21:06:01 +01:00
busname.c core: add unit_dbus_interface_from_type() to unit-name.h 2015-08-28 02:10:10 +02:00
busname.h remove unused includes 2015-02-23 23:53:42 +01:00
cgroup.c core: unified cgroup hierarchy support 2015-09-01 23:52:27 +02:00
cgroup.h core: unified cgroup hierarchy support 2015-09-01 23:52:27 +02:00
dbus-automount.c automount: add expire support 2015-04-21 20:23:41 +02:00
dbus-automount.h remove unused includes 2015-02-23 23:53:42 +01:00
dbus-busname.c remove unused includes 2015-02-23 23:53:42 +01:00
dbus-busname.h remove unused includes 2015-02-23 23:53:42 +01:00
dbus-cgroup.c core: unified cgroup hierarchy support 2015-09-01 23:52:27 +02:00
dbus-cgroup.h
dbus-device.c remove unused includes 2015-02-23 23:53:42 +01:00
dbus-device.h remove unused includes 2015-02-23 23:53:42 +01:00
dbus-execute.c core: drop spurious new line 2015-08-25 18:37:31 +02:00
dbus-execute.h
dbus-job.c sd-bus: drop bus parameter from message callback prototype 2015-04-29 18:36:25 +02:00
dbus-job.h sd-bus: drop bus parameter from message callback prototype 2015-04-29 18:36:25 +02:00
dbus-kill.c util: split out signal-util.[ch] from util.[ch] 2015-05-29 20:14:11 +02:00
dbus-kill.h
dbus-manager.c selinux: drop mac_selinux_unit_access_check_strv() 2015-08-27 16:29:01 +02:00
dbus-manager.h core: emit changes for NFailedUnits property 2015-02-26 09:38:50 -05:00
dbus-mount.c remove unused includes 2015-02-23 23:53:42 +01:00
dbus-mount.h
dbus-path.c remove unused includes 2015-02-23 23:53:42 +01:00
dbus-path.h remove unused includes 2015-02-23 23:53:42 +01:00
dbus-scope.c sd-bus: drop bus parameter from message callback prototype 2015-04-29 18:36:25 +02:00
dbus-scope.h
dbus-service.c remove unused includes 2015-02-23 23:53:42 +01:00
dbus-service.h
dbus-slice.c remove unused includes 2015-02-23 23:53:42 +01:00
dbus-slice.h
dbus-snapshot.c sd-bus: drop bus parameter from message callback prototype 2015-04-29 18:36:25 +02:00
dbus-snapshot.h sd-bus: drop bus parameter from message callback prototype 2015-04-29 18:36:25 +02:00
dbus-socket.c remove unused includes 2015-02-23 23:53:42 +01:00
dbus-socket.h
dbus-swap.c remove unused includes 2015-02-23 23:53:42 +01:00
dbus-swap.h
dbus-target.c remove unused includes 2015-02-23 23:53:42 +01:00
dbus-target.h remove unused includes 2015-02-23 23:53:42 +01:00
dbus-timer.c Bug #944: Deletion of unnecessary checks before a few calls of systemd functions 2015-08-17 10:45:30 +02:00
dbus-timer.h timer: timer can be a transient unit 2014-12-08 16:28:56 +01:00
dbus-unit.c core: unified cgroup hierarchy support 2015-09-01 23:52:27 +02:00
dbus-unit.h sd-bus: drop bus parameter from message callback prototype 2015-04-29 18:36:25 +02:00
dbus.c unit: add new macros to test for unit contexts 2015-08-31 13:20:43 +02:00
dbus.h core: rework policykit hookup 2015-02-18 18:56:27 +01:00
device.c core: add unit_dbus_interface_from_type() to unit-name.h 2015-08-28 02:10:10 +02:00
device.h device: rework how we enter tentative state 2015-04-24 12:29:05 +02:00
execute.c core: optionally create LOGIN_PROCESS or USER_PROCESS utmp entries 2015-08-24 22:46:45 +02:00
execute.h core: unified cgroup hierarchy support 2015-09-01 23:52:27 +02:00
failure-action.c core: rename SystemdRunningAs to ManagerRunningAs 2015-05-11 22:51:49 +02:00
failure-action.h core: introduce "poweroff" as new failure action types 2014-08-22 18:10:31 +02:00
hostname-setup.c hostname: Allow comments in /etc/hostname 2015-05-19 12:18:08 +02:00
hostname-setup.h
ima-setup.c ima-setup: write policy one line at a time 2015-06-11 09:05:02 -04:00
ima-setup.h
job.c core: adjust job completion message log levels 2015-07-21 19:28:17 +02:00
job.h core: when propagating restart requests due to deps, downgrade restart to try-restart 2015-05-19 18:21:19 +02:00
kill.c util: split out signal-util.[ch] from util.[ch] 2015-05-29 20:14:11 +02:00
kill.h
killall.c core: log oom during killing spree 2015-06-09 22:07:27 +02:00
killall.h
kmod-setup.c core: downgrade "Module inserted" message for kmod to DEBUG 2015-08-21 15:28:01 +02:00
kmod-setup.h
load-dropin.c remove unused includes 2015-02-23 23:53:42 +01:00
load-dropin.h Move dropin listing to shared 2014-12-16 00:30:33 -05:00
load-fragment-gperf.gperf.m4 core: optionally create LOGIN_PROCESS or USER_PROCESS utmp entries 2015-08-24 22:46:45 +02:00
load-fragment.c unit: unify how we assing slices to units 2015-08-31 13:20:43 +02:00
load-fragment.h core: optionally create LOGIN_PROCESS or USER_PROCESS utmp entries 2015-08-24 22:46:45 +02:00
locale-setup.c remove unused includes 2015-02-23 23:53:42 +01:00
locale-setup.h
loopback-setup.c sd-netlink: rename from sd-rtnl 2015-06-13 19:52:54 +02:00
loopback-setup.h
machine-id-setup.c namespace helpers: Allow entering a UID namespace 2015-08-17 08:52:13 +00:00
machine-id-setup.h machine-id-setup: add a machine_id_commit call to commit on disk a transient machine-id 2014-12-03 03:41:19 +01:00
macros.systemd.in rpm: add user macros 2014-10-27 22:34:09 -04:00
main.c Merge pull request #1111 from poettering/more-cgroup-fixes 2015-09-01 19:48:04 +02:00
Makefile
manager.c core: unified cgroup hierarchy support 2015-09-01 23:52:27 +02:00
manager.h core: unified cgroup hierarchy support 2015-09-01 23:52:27 +02:00
mount-setup.c core: unified cgroup hierarchy support 2015-09-01 23:52:27 +02:00
mount-setup.h mount-setup: remove mount_setup_late() 2014-11-14 15:18:56 +01:00
mount.c unit: unify how we assing slices to units 2015-08-31 13:20:43 +02:00
mount.h Default to /usr/bin/u?mount, configurable, rather than hard-coded /bin/u?mount. 2015-05-13 15:48:28 +02:00
namespace.c util: introduce CMSG_FOREACH() macro and make use of it everywhere 2015-06-10 19:29:47 +02:00
namespace.h core: Private*/Protect* options with RootDirectory 2015-05-18 18:47:45 +02:00
org.freedesktop.systemd1.conf systemctl: add add-wants and add-requires verbs 2014-10-08 12:44:00 +02:00
org.freedesktop.systemd1.policy.in.in core: rework policykit hookup 2015-02-18 18:56:27 +01:00
org.freedesktop.systemd1.service
path.c core: add unit_dbus_interface_from_type() to unit-name.h 2015-08-28 02:10:10 +02:00
path.h remove unused includes 2015-02-23 23:53:42 +01:00
scope.c core: unified cgroup hierarchy support 2015-09-01 23:52:27 +02:00
scope.h remove unused includes 2015-02-23 23:53:42 +01:00
selinux-access.c selinux: always use *_raw API from libselinux 2015-09-01 17:09:56 +02:00
selinux-access.h selinux: drop mac_selinux_unit_access_check_strv() 2015-08-27 16:29:01 +02:00
selinux-setup.c core: add attribute printf to null_log() 2015-08-30 19:21:31 -03:00
selinux-setup.h mac: add mac_ prefix to distinguish origin security apis 2014-10-28 14:31:48 +01:00
service.c core: unified cgroup hierarchy support 2015-09-01 23:52:27 +02:00
service.h service: remove unnecessary forward declare 2015-04-05 08:45:56 +02:00
show-status.c core: add missing show-status.[ch] 2014-03-03 22:27:25 +01:00
show-status.h core: add missing show-status.[ch] 2014-03-03 22:27:25 +01:00
shutdown.c shared: add terminal-util.[ch] 2015-04-11 00:34:02 +02:00
slice.c core: unified cgroup hierarchy support 2015-09-01 23:52:27 +02:00
slice.h remove unused includes 2015-02-23 23:53:42 +01:00
smack-setup.c fileio: consolidate write_string_file*() 2015-07-06 19:19:25 -04:00
smack-setup.h mac: add mac_ prefix to distinguish origin security apis 2014-10-28 14:31:48 +01:00
snapshot.c core: add unit_dbus_interface_from_type() to unit-name.h 2015-08-28 02:10:10 +02:00
snapshot.h remove unused includes 2015-02-23 23:53:42 +01:00
socket.c unit: unify how we assing slices to units 2015-08-31 13:20:43 +02:00
socket.h core: expose consumed CPU time per unit 2015-03-02 12:15:25 +01:00
swap.c unit: unify how we assing slices to units 2015-08-31 13:20:43 +02:00
swap.h core: expose consumed CPU time per unit 2015-03-02 12:15:25 +01:00
system.conf Do not advertise .d snippets over main config file 2015-03-03 19:10:21 -05:00
systemd.pc.in build-sys: move systemd.pc from pkgconfiglibdir back into pkgconfigdatadir 2015-04-21 20:35:17 +02:00
target.c core: add unit_dbus_interface_from_type() to unit-name.h 2015-08-28 02:10:10 +02:00
target.h remove unused includes 2015-02-23 23:53:42 +01:00
timer.c core: add unit_dbus_interface_from_type() to unit-name.h 2015-08-28 02:10:10 +02:00
timer.h remove unused includes 2015-02-23 23:53:42 +01:00
transaction.c core: properly handle jobs that are suppressed to JOB_NOPs when propagating restarts 2015-05-21 20:49:24 +02:00
transaction.h
umount.c core: fix CID 996302 2015-06-12 10:24:26 +05:30
umount.h
unit-printf.c core: rename SystemdRunningAs to ManagerRunningAs 2015-05-11 22:51:49 +02:00
unit-printf.h
unit.c core: unified cgroup hierarchy support 2015-09-01 23:52:27 +02:00
unit.h core: unified cgroup hierarchy support 2015-09-01 23:52:27 +02:00
user.conf core: Support system.conf.d and user.conf.d directories in the usual search paths 2014-11-29 13:55:31 -05:00