Merge pull request #29530 from poettering/debug-log-tweaks

pid1: various debug logging tweaks
This commit is contained in:
Mike Yuan
2023-10-11 20:29:00 +08:00
committed by GitHub
4 changed files with 19 additions and 5 deletions
+4 -1
View File
@@ -156,8 +156,11 @@ uint64_t system_tasks_max(void) {
if (r < 0)
log_debug_errno(r, "Failed to determine cgroup root path, ignoring: %m");
else {
/* We'll have the "pids.max" attribute on the our root cgroup only if we are in a
* CLONE_NEWCGROUP namespace. On the top-level namespace this attribute is missing, hence
* suppress any message about that */
r = cg_get_attribute_as_uint64("pids", root, "pids.max", &c);
if (r < 0)
if (r < 0 && r != -ENODATA)
log_debug_errno(r, "Failed to read pids.max attribute of root cgroup, ignoring: %m");
}
+4 -1
View File
@@ -228,11 +228,14 @@ int lsm_bpf_cleanup(const Unit *u) {
if (!u->manager->restrict_fs)
return 0;
if (u->cgroup_id == 0)
return 0;
int fd = sym_bpf_map__fd(u->manager->restrict_fs->maps.cgroup_hash);
if (fd < 0)
return log_unit_error_errno(u, errno, "bpf-lsm: Failed to get BPF map fd: %m");
if (sym_bpf_map_delete_elem(fd, &u->cgroup_id) != 0)
if (sym_bpf_map_delete_elem(fd, &u->cgroup_id) != 0 && errno != ENOENT)
return log_unit_debug_errno(u, errno, "bpf-lsm: Failed to delete cgroup entry from LSM BPF map: %m");
return 0;
+10 -2
View File
@@ -54,6 +54,8 @@ void fdset_close(FDSet *s) {
void *p;
while ((p = set_steal_first(MAKE_SET(s)))) {
int fd = PTR_TO_FD(p);
/* Valgrind's fd might have ended up in this set here, due to fdset_new_fill(). We'll ignore
* all failures here, so that the EBADFD that valgrind will return us on close() doesn't
* influence us */
@@ -62,8 +64,14 @@ void fdset_close(FDSet *s) {
* which has no effect at all, since they are only duplicates. So don't be surprised about
* these log messages. */
log_debug("Closing set fd %i", PTR_TO_FD(p));
(void) close_nointr(PTR_TO_FD(p));
if (DEBUG_LOGGING) {
_cleanup_free_ char *path = NULL;
(void) fd_get_path(fd, &path);
log_debug("Closing set fd %i (%s)", fd, strna(path));
}
(void) close_nointr(fd);
}
}
+1 -1
View File
@@ -60,7 +60,7 @@ static bool is_survivor_cgroup(pid_t pid) {
/* 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(cgroup_path, "trusted.survive_final_kill_signal");
if (r < 0)
if (r < 0 && !ERRNO_IS_NEG_XATTR_ABSENT(r))
log_debug_errno(r,
"Failed to get survive_final_kill_signal xattr of %s, ignoring: %m",
cgroup_path);