This is an automated email from the ASF dual-hosted git repository.
zykkk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new c6957d6c6e8 [fix](cgroup) Fix cgroup compatibility with MacOS (#39398)
c6957d6c6e8 is described below
commit c6957d6c6e84ae47c3a40bbb71dc545df56521af
Author: Xinyi Zou <[email protected]>
AuthorDate: Thu Aug 15 14:50:24 2024 +0800
[fix](cgroup) Fix cgroup compatibility with MacOS (#39398)
cgroupv2 is not visible to MacOS
---
be/src/util/cgroup_util.cpp | 4 ++++
be/src/util/cgroup_util.h | 9 ++++++---
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/be/src/util/cgroup_util.cpp b/be/src/util/cgroup_util.cpp
index 8109e38559f..8f64fe699c6 100644
--- a/be/src/util/cgroup_util.cpp
+++ b/be/src/util/cgroup_util.cpp
@@ -193,6 +193,7 @@ std::string CGroupUtil::cgroupv2_of_process() {
}
std::optional<std::string> CGroupUtil::get_cgroupsv2_path(const std::string&
subsystem) {
+#if defined(OS_LINUX)
if (!CGroupUtil::cgroupsv2_enable()) {
return {};
}
@@ -209,6 +210,9 @@ std::optional<std::string>
CGroupUtil::get_cgroupsv2_path(const std::string& sub
current_cgroup = current_cgroup.parent_path();
}
return {};
+#else
+ return {};
+#endif
}
Status CGroupUtil::read_int_line_from_cgroup_file(const std::filesystem::path&
file_path,
diff --git a/be/src/util/cgroup_util.h b/be/src/util/cgroup_util.h
index cf922ba5063..bc1417453f4 100644
--- a/be/src/util/cgroup_util.h
+++ b/be/src/util/cgroup_util.h
@@ -26,11 +26,9 @@
#include "common/status.h"
namespace doris {
-#if defined(OS_LINUX)
// I think it is possible to mount the cgroups hierarchy somewhere else (e.g.
when in containers).
// /sys/fs/cgroup was still symlinked to the actual mount in the cases that I
have seen.
static inline const std::filesystem::path default_cgroups_mount =
"/sys/fs/cgroup";
-#endif
/* Cgroup debugging steps
* CgroupV1:
@@ -52,7 +50,12 @@ class CGroupUtil {
public:
enum class CgroupsVersion : uint8_t { V1, V2 };
- // detect if cgroup is enabled
+ // Detect if cgroup is enabled.
+ // If true, it only means that the OS allows the use of Cgroup v1 or v2,
+ // not that the current BE process is using Cgroup.
+ // To confirm whether the process is using Cgroup need to use
`find_global_cgroupv1` or `cgroupv2_of_process`.
+ // To confirm whether the process is using a subsystem of Cgroup,
+ // need to use `find_abs_cgroupv1_path` or `get_cgroupsv2_path`.
static bool cgroupsv1_enable();
static bool cgroupsv2_enable();
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]