cgroup: run PID 1 in the root cgroup
This way cleaning up the cgroup tree on shutdown is a lot easier since we are in the root dir. Also PID 1 was previously artificially placed in system.slice, even though our rule actually was not to have processes in slices. The root slice otoh is magic anyway, so having PID 1 in there sounds less surprising. Of course, this means that PID is scheduled against the three top-level slices.
This commit is contained in:
parent
2270309471
commit
15c60e99a9
|
@ -589,8 +589,8 @@ pid_t unit_search_main_pid(Unit *u) {
|
|||
|
||||
int manager_setup_cgroup(Manager *m) {
|
||||
_cleanup_free_ char *path = NULL;
|
||||
char *e;
|
||||
int r;
|
||||
char *e, *a;
|
||||
|
||||
assert(m);
|
||||
|
||||
|
@ -610,9 +610,13 @@ int manager_setup_cgroup(Manager *m) {
|
|||
return r;
|
||||
}
|
||||
|
||||
/* Already in /system.slice? If so, let's cut this off again */
|
||||
/* LEGACY: Already in /system.slice? If so, let's cut this
|
||||
* off. This is to support live upgrades from older systemd
|
||||
* versions where PID 1 was moved there. */
|
||||
if (m->running_as == SYSTEMD_SYSTEM) {
|
||||
e = endswith(m->cgroup_root, "/" SPECIAL_SYSTEM_SLICE);
|
||||
if (!e)
|
||||
e = endswith(m->cgroup_root, "/system");
|
||||
if (e)
|
||||
*e = 0;
|
||||
}
|
||||
|
@ -643,12 +647,8 @@ int manager_setup_cgroup(Manager *m) {
|
|||
log_debug("Release agent already installed.");
|
||||
}
|
||||
|
||||
/* 4. Realize the system slice and put us in there */
|
||||
if (m->running_as == SYSTEMD_SYSTEM) {
|
||||
a = strappenda(m->cgroup_root, "/" SPECIAL_SYSTEM_SLICE);
|
||||
r = cg_create_and_attach(SYSTEMD_CGROUP_CONTROLLER, a, 0);
|
||||
} else
|
||||
r = cg_create_and_attach(SYSTEMD_CGROUP_CONTROLLER, m->cgroup_root, 0);
|
||||
/* 4. Make sure we are in the root cgroup */
|
||||
r = cg_create_and_attach(SYSTEMD_CGROUP_CONTROLLER, m->cgroup_root, 0);
|
||||
if (r < 0) {
|
||||
log_error("Failed to create root cgroup hierarchy: %s", strerror(-r));
|
||||
return r;
|
||||
|
|
Loading…
Reference in New Issue