Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] Setup cgroup v2 in C++ #49416

Merged
merged 23 commits into from
Jan 9, 2025
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
place process to default cgroup
Signed-off-by: dentiny <dentinyhao@gmail.com>
  • Loading branch information
dentiny committed Dec 26, 2024
commit c5e3fd75a6cfc900a5e55aefa63a8173a801fb50
12 changes: 12 additions & 0 deletions src/ray/common/cgroup/cgroup_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,17 @@ bool RemoveCtxFromDefaultCgroupV2(const PhysicalModeExecutionContext &ctx) {
return true;
}

void PlaceProcessIntoDefaultCgroup(const PhysicalModeExecutionContext &ctx) {
const std::string procs_path =
absl::StrFormat("%s/%s/cgroup.procs", ctx.cgroup_directory, kDefaultCgroupV2Id);
{
std::ofstream out_file{procs_path.data(), std::ios::out};
out_file << ctx.pid;
}

return;
}

} // namespace

/*static*/ std::unique_ptr<CgroupV2Setup> CgroupV2Setup::New(
Expand Down Expand Up @@ -178,6 +189,7 @@ CgroupV2Setup::~CgroupV2Setup() {
const PhysicalModeExecutionContext &ctx) {
// Delete the dedicated cgroup if max memory specified.
if (ctx.max_memory > 0) {
PlaceProcessIntoDefaultCgroup(ctx);
return DeleteCgroupV2(ctx);
}

Expand Down
Loading