pid1,cgroup-show: ignore -EOPNOTSUPP in cg_read_pid()
Signed-off-by: zhaoxiaohu <zhaoxiaohu@kuaishou.com>
This commit is contained in:
parent
9b963cce2e
commit
2f45b43460
@ -0,0 +1,86 @@
|
|||||||
|
From 9029ab8ae01f315cc9ce795ad52e09013e10d893 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
||||||
|
Date: Thu, 13 Jan 2022 00:09:38 +0900
|
||||||
|
Subject: [PATCH] pid1,cgroup-show: ignore -EOPNOTSUPP in cg_read_pid()
|
||||||
|
|
||||||
|
The function is called in recursion, and cgroup.procs in some subcgroups
|
||||||
|
may not be read.
|
||||||
|
|
||||||
|
Fixes #22089.
|
||||||
|
|
||||||
|
Reference: https://github.com/systemd/systemd/pull/22095/commits/c41911ce12d23d28b090b51c200db1e1e8ee7ce7
|
||||||
|
|
||||||
|
Signed-off-by: zhaoxiaohu <zhaoxiaohu@kuaishou.com>
|
||||||
|
Signed-off-by: yuwang <yuwang@kuaishou.com>
|
||||||
|
---
|
||||||
|
src/core/dbus-unit.c | 8 ++++++--
|
||||||
|
src/shared/cgroup-show.c | 17 ++++++++++++-----
|
||||||
|
2 files changed, 18 insertions(+), 7 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/core/dbus-unit.c b/src/core/dbus-unit.c
|
||||||
|
index 24e4d25..0640d3e 100644
|
||||||
|
--- a/src/core/dbus-unit.c
|
||||||
|
+++ b/src/core/dbus-unit.c
|
||||||
|
@@ -1295,11 +1295,15 @@ static int append_cgroup(sd_bus_message *reply, const char *p, Set *pids) {
|
||||||
|
for (;;) {
|
||||||
|
pid_t pid;
|
||||||
|
|
||||||
|
+ /* libvirt / qemu uses threaded mode and cgroup.procs cannot be read at the lower levels.
|
||||||
|
+ * From https://www.kernel.org/doc/html/latest/admin-guide/cgroup-v2.html#threads,
|
||||||
|
+ * “cgroup.procs” in a threaded domain cgroup contains the PIDs of all processes in
|
||||||
|
+ * the subtree and is not readable in the subtree proper. */
|
||||||
|
r = cg_read_pid(f, &pid);
|
||||||
|
+ if (IN_SET(r, 0, -EOPNOTSUPP))
|
||||||
|
+ break;
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
- if (r == 0)
|
||||||
|
- break;
|
||||||
|
|
||||||
|
if (is_kernel_thread(pid) > 0)
|
||||||
|
continue;
|
||||||
|
diff --git a/src/shared/cgroup-show.c b/src/shared/cgroup-show.c
|
||||||
|
index c7e63be..c324652 100644
|
||||||
|
--- a/src/shared/cgroup-show.c
|
||||||
|
+++ b/src/shared/cgroup-show.c
|
||||||
|
@@ -86,7 +86,6 @@ static int show_cgroup_one_by_path(
|
||||||
|
_cleanup_fclose_ FILE *f = NULL;
|
||||||
|
_cleanup_free_ char *p = NULL;
|
||||||
|
size_t n = 0;
|
||||||
|
- pid_t pid;
|
||||||
|
char *fn;
|
||||||
|
int r;
|
||||||
|
|
||||||
|
@@ -99,7 +98,18 @@ static int show_cgroup_one_by_path(
|
||||||
|
if (!f)
|
||||||
|
return -errno;
|
||||||
|
|
||||||
|
- while ((r = cg_read_pid(f, &pid)) > 0) {
|
||||||
|
+ for (;;) {
|
||||||
|
+ pid_t pid;
|
||||||
|
+
|
||||||
|
+ /* libvirt / qemu uses threaded mode and cgroup.procs cannot be read at the lower levels.
|
||||||
|
+ * From https://www.kernel.org/doc/html/latest/admin-guide/cgroup-v2.html#threads,
|
||||||
|
+ * “cgroup.procs” in a threaded domain cgroup contains the PIDs of all processes in
|
||||||
|
+ * the subtree and is not readable in the subtree proper. */
|
||||||
|
+ r = cg_read_pid(f, &pid);
|
||||||
|
+ if (IN_SET(r, 0, -EOPNOTSUPP))
|
||||||
|
+ break;
|
||||||
|
+ if (r < 0)
|
||||||
|
+ return r;
|
||||||
|
|
||||||
|
if (!(flags & OUTPUT_KERNEL_THREADS) && is_kernel_thread(pid) > 0)
|
||||||
|
continue;
|
||||||
|
@@ -110,9 +120,6 @@ static int show_cgroup_one_by_path(
|
||||||
|
pids[n++] = pid;
|
||||||
|
}
|
||||||
|
|
||||||
|
- if (r < 0)
|
||||||
|
- return r;
|
||||||
|
-
|
||||||
|
show_pid_array(pids, n, prefix, n_columns, false, more, flags);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
|
|
||||||
@ -25,7 +25,7 @@
|
|||||||
Name: systemd
|
Name: systemd
|
||||||
Url: https://systemd.io/
|
Url: https://systemd.io/
|
||||||
Version: 249
|
Version: 249
|
||||||
Release: 93
|
Release: 94
|
||||||
License: MIT and LGPLv2+ and GPLv2+
|
License: MIT and LGPLv2+ and GPLv2+
|
||||||
Summary: System and Service Manager
|
Summary: System and Service Manager
|
||||||
|
|
||||||
@ -696,6 +696,7 @@ Patch6643: backport-importd-Always-specify-file-unpacked-by-tar.patch
|
|||||||
Patch6644: backport-docs-remove-dev-tty-confusion.patch
|
Patch6644: backport-docs-remove-dev-tty-confusion.patch
|
||||||
Patch6645: backport-wait-online-make-manager_link_is_online-return-0-whe.patch
|
Patch6645: backport-wait-online-make-manager_link_is_online-return-0-whe.patch
|
||||||
Patch6646: backport-psi-util-fix-error-handling.patch
|
Patch6646: backport-psi-util-fix-error-handling.patch
|
||||||
|
Patch6647: backport-pid1-cgroup-show-ignore-EOPNOTSUPP-in-cg_read_pid.patch
|
||||||
|
|
||||||
Patch9001: update-rtc-with-system-clock-when-shutdown.patch
|
Patch9001: update-rtc-with-system-clock-when-shutdown.patch
|
||||||
Patch9002: udev-add-actions-while-rename-netif-failed.patch
|
Patch9002: udev-add-actions-while-rename-netif-failed.patch
|
||||||
@ -2210,6 +2211,9 @@ grep -q -E '^KEYMAP="?fi-latin[19]"?' /etc/vconsole.conf 2>/dev/null &&
|
|||||||
/usr/bin/systemd-cryptenroll
|
/usr/bin/systemd-cryptenroll
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Wed Dec 04 2024 zhangyao <zhangyao108@huawei.com> - 249-94
|
||||||
|
- add backport-pid1-cgroup-show-ignore-EOPNOTSUPP-in-cg_read_pid.patch
|
||||||
|
|
||||||
* Wed Dec 04 2024 zhangyao <zhangyao108@huawei.com> - 249-93
|
* Wed Dec 04 2024 zhangyao <zhangyao108@huawei.com> - 249-93
|
||||||
- add backport-psi-util-fix-error-handling.patch
|
- add backport-psi-util-fix-error-handling.patch
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user