cgroup-util: drop "controller" argument from various cgroup helper calls

systemd's own cgroup hierarchy is special to us, we use it to actually
manage processes. Because of that many calls tha apply to cgroups are
only ever called with the SYSTEMD_CGROUP_CONTROLLER as controller
argument. Let's hence remove the argument altogether.

This in particular touches the kill and xattr routines.

This changes no behaviour, we just drop an argument that is always set
to the same value anyway.

This is preparation to eventually getting rid of the cgroupvs1, because
on cgroupvs2 the cgroup paths do not change for different controllers,
there's only a single hierarchy there.
This commit is contained in:
Lennart Poettering
2023-10-05 11:11:04 +02:00
parent 5ee3c914a4
commit bd1791b597
11 changed files with 119 additions and 116 deletions
+1 -1
View File
@@ -352,7 +352,7 @@ int cg_attach(const char *controller, const char *path, pid_t pid) {
xsprintf(c, PID_FMT "\n", pid);
r = write_string_file(fs, c, WRITE_STRING_FILE_DISABLE_BUFFER);
if (r == -EOPNOTSUPP && cg_is_threaded(controller, path) > 0)
if (r == -EOPNOTSUPP && cg_is_threaded(path) > 0)
/* When the threaded mode is used, we cannot read/write the file. Let's return recognizable error. */
return -EUCLEAN;
if (r < 0)
+2 -4
View File
@@ -56,12 +56,10 @@ static bool is_survivor_cgroup(pid_t pid) {
return false;
}
r = cg_get_xattr_bool(SYSTEMD_CGROUP_CONTROLLER, cgroup_path, "user.survive_final_kill_signal");
r = cg_get_xattr_bool(cgroup_path, "user.survive_final_kill_signal");
/* user xattr support was added to kernel v5.7, try with the trusted namespace as a fallback */
if (ERRNO_IS_NEG_XATTR_ABSENT(r))
r = cg_get_xattr_bool(SYSTEMD_CGROUP_CONTROLLER,
cgroup_path,
"trusted.survive_final_kill_signal");
r = cg_get_xattr_bool(cgroup_path, "trusted.survive_final_kill_signal");
if (r < 0)
log_debug_errno(r,
"Failed to get survive_final_kill_signal xattr of %s, ignoring: %m",