Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions be/src/util/cgroup_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {};
}
Expand All @@ -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,
Expand Down
9 changes: 6 additions & 3 deletions be/src/util/cgroup_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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();

Expand Down