core: do not set up cgroup runtime on coldplug
Currently, unit_setup_cgroup_runtime() is called in various _coldplug() functions if the unit is not inactive. That seems unnecessary though, and kinda defeats the purpose of CGroupRuntime. If we need to fork off a process for the unit or got something during deserialization, the CGroupRuntime would be automatically set up by unit_prepare_exec() / cgroup_runtime_deserialize_one(). Otherwise it would mean the cgroup doesn't exist and we don't need to allocate that in the first place. Plus, note that socket units might also carry a cgroup with ExecStartPre=/ExecStartPost=/... Hence the existing code is really inconsistent.
This commit is contained in:
+1
-3
@@ -764,10 +764,8 @@ static int mount_coldplug(Unit *u) {
|
||||
return r;
|
||||
}
|
||||
|
||||
if (!IN_SET(m->deserialized_state, MOUNT_DEAD, MOUNT_FAILED)) {
|
||||
if (!IN_SET(m->deserialized_state, MOUNT_DEAD, MOUNT_FAILED))
|
||||
(void) unit_setup_exec_runtime(u);
|
||||
(void) unit_setup_cgroup_runtime(u);
|
||||
}
|
||||
|
||||
mount_set_state(m, m->deserialized_state);
|
||||
return 0;
|
||||
|
||||
@@ -1366,7 +1366,6 @@ static int service_coldplug(Unit *u) {
|
||||
SERVICE_DEAD_RESOURCES_PINNED)) {
|
||||
(void) unit_enqueue_rewatch_pids(u);
|
||||
(void) unit_setup_exec_runtime(u);
|
||||
(void) unit_setup_cgroup_runtime(u);
|
||||
}
|
||||
|
||||
if (IN_SET(s->deserialized_state, SERVICE_START_POST, SERVICE_RUNNING, SERVICE_RELOAD, SERVICE_RELOAD_SIGNAL, SERVICE_RELOAD_NOTIFY))
|
||||
|
||||
+1
-3
@@ -548,10 +548,8 @@ static int swap_coldplug(Unit *u) {
|
||||
return r;
|
||||
}
|
||||
|
||||
if (!IN_SET(new_state, SWAP_DEAD, SWAP_FAILED)) {
|
||||
if (!IN_SET(new_state, SWAP_DEAD, SWAP_FAILED))
|
||||
(void) unit_setup_exec_runtime(u);
|
||||
(void) unit_setup_cgroup_runtime(u);
|
||||
}
|
||||
|
||||
swap_set_state(s, new_state);
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user