From: @zhang-yao-2022 Reviewed-by: @xujing99 Signed-off-by: @xujing99
This commit is contained in:
commit
7abd5c9640
65
backport-cgroup-util-introduce-cg_is_threaded.patch
Normal file
65
backport-cgroup-util-introduce-cg_is_threaded.patch
Normal file
@ -0,0 +1,65 @@
|
||||
From 084e7706c25bf6cf0d6af4cc07fb1bb47e26b25e Mon Sep 17 00:00:00 2001
|
||||
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
||||
Date: Sun, 13 Feb 2022 20:39:04 +0900
|
||||
Subject: [PATCH] cgroup-util: introduce cg_is_threaded()
|
||||
|
||||
Reference: https://github.com/systemd/systemd/pull/22498/commits/084e7706c25bf6cf0d6af4cc07fb1bb47e26b25e
|
||||
|
||||
Signed-off-by: rpm-build <rpm-build>
|
||||
Signed-off-by: yuwang <yuwang@kuaishou.com>
|
||||
---
|
||||
src/basic/cgroup-util.c | 24 ++++++++++++++++++++++++
|
||||
src/basic/cgroup-util.h | 2 ++
|
||||
2 files changed, 26 insertions(+)
|
||||
|
||||
diff --git a/src/basic/cgroup-util.c b/src/basic/cgroup-util.c
|
||||
index 79089ac..130536c 100644
|
||||
--- a/src/basic/cgroup-util.c
|
||||
+++ b/src/basic/cgroup-util.c
|
||||
@@ -1642,6 +1642,30 @@ int cg_slice_to_path(const char *unit, char **ret) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
+int cg_is_threaded(const char *controller, const char *path) {
|
||||
+ _cleanup_free_ char *fs = NULL, *contents = NULL;
|
||||
+ _cleanup_strv_free_ char **v = NULL;
|
||||
+ int r;
|
||||
+
|
||||
+ r = cg_get_path(controller, path, "cgroup.type", &fs);
|
||||
+ if (r < 0)
|
||||
+ return r;
|
||||
+
|
||||
+ r = read_full_virtual_file(fs, &contents, NULL);
|
||||
+ if (r == -ENOENT)
|
||||
+ return false; /* Assume no. */
|
||||
+ if (r < 0)
|
||||
+ return r;
|
||||
+
|
||||
+ v = strv_split(contents, NULL);
|
||||
+ if (!v)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ /* If the cgroup is in the threaded mode, it contains "threaded".
|
||||
+ * If one of the parents or siblings is in the threaded mode, it may contain "invalid". */
|
||||
+ return strv_contains(v, "threaded") || strv_contains(v, "invalid");
|
||||
+}
|
||||
+
|
||||
int cg_set_attribute(const char *controller, const char *path, const char *attribute, const char *value) {
|
||||
_cleanup_free_ char *p = NULL;
|
||||
int r;
|
||||
diff --git a/src/basic/cgroup-util.h b/src/basic/cgroup-util.h
|
||||
index faa253b..baeb8c4 100644
|
||||
--- a/src/basic/cgroup-util.h
|
||||
+++ b/src/basic/cgroup-util.h
|
||||
@@ -188,6 +188,8 @@ int cg_pid_get_path(const char *controller, pid_t pid, char **path);
|
||||
|
||||
int cg_rmdir(const char *controller, const char *path);
|
||||
|
||||
+int cg_is_threaded(const char *controller, const char *path);
|
||||
+
|
||||
typedef enum {
|
||||
CG_KEY_MODE_GRACEFUL = 1 << 0,
|
||||
} CGroupKeyMode;
|
||||
--
|
||||
2.33.0
|
||||
|
||||
@ -0,0 +1,50 @@
|
||||
From 702cf08fceaa7df8476e56e3648b211e58700bc0 Mon Sep 17 00:00:00 2001
|
||||
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
||||
Date: Sun, 13 Feb 2022 20:52:53 +0900
|
||||
Subject: [PATCH] core/execute: warn when threaded mode is detected
|
||||
|
||||
Prompted by #22486.
|
||||
|
||||
Reference: https://github.com/systemd/systemd/pull/22498/commits/702cf08fceaa7df8476e56e3648b211e58700bc0
|
||||
|
||||
Signed-off-by: rpm-build <rpm-build>
|
||||
Signed-off-by: yuwang <yuwang@kuaishou.com>
|
||||
---
|
||||
src/core/execute.c | 6 ++++++
|
||||
src/shared/cgroup-setup.c | 3 +++
|
||||
2 files changed, 9 insertions(+)
|
||||
|
||||
diff --git a/src/core/execute.c b/src/core/execute.c
|
||||
index 9185a6f..10665b1 100644
|
||||
--- a/src/core/execute.c
|
||||
+++ b/src/core/execute.c
|
||||
@@ -3919,6 +3919,12 @@ static int exec_child(
|
||||
}
|
||||
|
||||
r = cg_attach_everywhere(params->cgroup_supported, p, 0, NULL, NULL);
|
||||
+ if (r == -EUCLEAN) {
|
||||
+ *exit_status = EXIT_CGROUP;
|
||||
+ return log_unit_error_errno(unit, r, "Failed to attach process to cgroup %s "
|
||||
+ "because the cgroup or one of its parents or "
|
||||
+ "siblings is in the threaded mode: %m", p);
|
||||
+ }
|
||||
if (r < 0) {
|
||||
*exit_status = EXIT_CGROUP;
|
||||
return log_unit_error_errno(unit, r, "Failed to attach to cgroup %s: %m", p);
|
||||
diff --git a/src/shared/cgroup-setup.c b/src/shared/cgroup-setup.c
|
||||
index f197f71..391b32f 100644
|
||||
--- a/src/shared/cgroup-setup.c
|
||||
+++ b/src/shared/cgroup-setup.c
|
||||
@@ -268,6 +268,9 @@ 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)
|
||||
+ /* When the threaded mode is used, we cannot read/write the file. Let's return recognizable error. */
|
||||
+ return -EUCLEAN;
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
--
|
||||
2.33.0
|
||||
|
||||
@ -25,7 +25,7 @@
|
||||
Name: systemd
|
||||
Url: https://systemd.io/
|
||||
Version: 249
|
||||
Release: 94
|
||||
Release: 95
|
||||
License: MIT and LGPLv2+ and GPLv2+
|
||||
Summary: System and Service Manager
|
||||
|
||||
@ -697,6 +697,8 @@ Patch6644: backport-docs-remove-dev-tty-confusion.patch
|
||||
Patch6645: backport-wait-online-make-manager_link_is_online-return-0-whe.patch
|
||||
Patch6646: backport-psi-util-fix-error-handling.patch
|
||||
Patch6647: backport-pid1-cgroup-show-ignore-EOPNOTSUPP-in-cg_read_pid.patch
|
||||
Patch6648: backport-cgroup-util-introduce-cg_is_threaded.patch
|
||||
Patch6649: backport-core-execute-warn-when-threaded-mode-is-detected.patch
|
||||
|
||||
Patch9001: update-rtc-with-system-clock-when-shutdown.patch
|
||||
Patch9002: udev-add-actions-while-rename-netif-failed.patch
|
||||
@ -2211,6 +2213,10 @@ grep -q -E '^KEYMAP="?fi-latin[19]"?' /etc/vconsole.conf 2>/dev/null &&
|
||||
/usr/bin/systemd-cryptenroll
|
||||
|
||||
%changelog
|
||||
* Mon Dec 09 2024 zhangyao <zhangyao108@huawei.com> - 249-95
|
||||
- add backport-cgroup-util-introduce-cg_is_threaded.patch
|
||||
backport-core-execute-warn-when-threaded-mode-is-detected.patch
|
||||
|
||||
* Wed Dec 04 2024 zhangyao <zhangyao108@huawei.com> - 249-94
|
||||
- add backport-pid1-cgroup-show-ignore-EOPNOTSUPP-in-cg_read_pid.patch
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user