51 lines
2.0 KiB
Diff
51 lines
2.0 KiB
Diff
|
|
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
|
||
|
|
|