From 17cfe4173faf05815a3a29b7ed851221904d70f5 Mon Sep 17 00:00:00 2001 From: Ibrahim Rabbani Date: Thu, 11 Sep 2025 21:24:12 -0700 Subject: [PATCH 1/5] [core] attempting to fix mac-os build Signed-off-by: Ibrahim Rabbani --- src/ray/common/cgroup2/BUILD.bazel | 35 ++++----- .../cgroup2/noop_sysfs_cgroup_driver.cc | 74 +++++++++++++++++++ src/ray/common/cgroup2/sysfs_cgroup_driver.cc | 7 ++ src/ray/common/cgroup2/sysfs_cgroup_driver.h | 15 ++-- 4 files changed, 102 insertions(+), 29 deletions(-) create mode 100644 src/ray/common/cgroup2/noop_sysfs_cgroup_driver.cc diff --git a/src/ray/common/cgroup2/BUILD.bazel b/src/ray/common/cgroup2/BUILD.bazel index a3f39c7040ad..9431d096755f 100644 --- a/src/ray/common/cgroup2/BUILD.bazel +++ b/src/ray/common/cgroup2/BUILD.bazel @@ -12,7 +12,10 @@ ray_cc_library( ":is_linux": ["cgroup_manager.cc"], "//conditions:default": ["noop_cgroup_manager.cc"], }), - hdrs = ["cgroup_manager.h"], + hdrs = [ + "cgroup_manager.h", + "scoped_cgroup_operation.h" + ], visibility = ["//visibility:public"], deps = [ ":cgroup_driver_interface", @@ -21,7 +24,6 @@ ray_cc_library( "//src/ray/common:status_or", ] + select({ ":is_linux": [ - ":scoped_cgroup_operation", "//src/ray/util:logging", "@com_google_absl//absl/strings", ], @@ -55,35 +57,28 @@ ray_cc_library( ray_cc_library( name = "sysfs_cgroup_driver", - srcs = ["sysfs_cgroup_driver.cc"], + srcs = select({ + ":is_linux": ["sysfs_cgroup_driver.cc"], + "//conditions:default": ["noop_sysfs_cgroup_driver.cc"], + }), hdrs = [ "sysfs_cgroup_driver.h", ], - target_compatible_with = [ - "@platforms//os:linux", - ], visibility = ["//visibility:public"], deps = [ ":cgroup_driver_interface", "//src/ray/common:status", "//src/ray/common:status_or", - "//src/ray/util:logging", - "@com_google_absl//absl/strings", - ], + ] + select({ + ":is_linux": [ + "//src/ray/util:logging", + "@com_google_absl//absl/strings", + ], + "//conditions:default": [], + }) ) # Private Targets. -ray_cc_library( - name = "scoped_cgroup_operation", - hdrs = [ - "scoped_cgroup_operation.h", - ], - target_compatible_with = [ - "@platforms//os:linux", - ], - visibility = [":__subpackages__"], -) - ray_cc_library( name = "fake_cgroup_driver", hdrs = [ diff --git a/src/ray/common/cgroup2/noop_sysfs_cgroup_driver.cc b/src/ray/common/cgroup2/noop_sysfs_cgroup_driver.cc new file mode 100644 index 000000000000..b448f021a8ad --- /dev/null +++ b/src/ray/common/cgroup2/noop_sysfs_cgroup_driver.cc @@ -0,0 +1,74 @@ +// Copyright 2025 The Ray Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#include + +#include "ray/common/cgroup2/sysfs_cgroup_driver.h" +#include "ray/common/status.h" +#include "ray/common/status_or.h" + +namespace ray { +Status SysFsCgroupDriver::CheckCgroupv2Enabled() { return Status::OK(); } + +Status SysFsCgroupDriver::CheckCgroup(const std::string &cgroup_path) { + return Status::OK(); +} + +Status SysFsCgroupDriver::CreateCgroup(const std::string &cgroup_path) { + return Status::OK(); +} + +Status SysFsCgroupDriver::DeleteCgroup(const std::string &cgroup_path) { + return Status::OK(); +} + +StatusOr> SysFsCgroupDriver::GetAvailableControllers( + const std::string &cgroup_dir) { + return std::unordered_set{}; +} + +StatusOr> SysFsCgroupDriver::GetEnabledControllers( + const std::string &cgroup_dir) { + return std::unordered_set{}; +} + +Status SysFsCgroupDriver::MoveAllProcesses(const std::string &from, + const std::string &to) { + return Status::OK(); +} + +Status SysFsCgroupDriver::EnableController(const std::string &cgroup_path, + const std::string &controller) { + return Status::OK(); +} + +Status SysFsCgroupDriver::DisableController(const std::string &cgroup_path, + const std::string &controller) { + return Status::OK(); +} + +Status SysFsCgroupDriver::AddConstraint(const std::string &cgroup_path, + const std::string &controller, + const std::string &constraint, + const std::string &constraint_value) { + return Status::OK(); +} + +StatusOr> SysFsCgroupDriver::ReadControllerFile( + const std::string &controller_file_path) { + return std::unordered_set{}; +} + +} // namespace ray diff --git a/src/ray/common/cgroup2/sysfs_cgroup_driver.cc b/src/ray/common/cgroup2/sysfs_cgroup_driver.cc index b36960c6127c..5f121857f5c5 100644 --- a/src/ray/common/cgroup2/sysfs_cgroup_driver.cc +++ b/src/ray/common/cgroup2/sysfs_cgroup_driver.cc @@ -37,6 +37,13 @@ #include "ray/common/status.h" #include "ray/common/status_or.h" +// Used to identify if a filesystem is mounted using cgroupv2. +// See: https://docs.kernel.org/admin-guide/cgroup-v2.html#mounting +#ifndef CGROUP2_SUPER_MAGIC +#define CGROUP2_SUPER_MAGIC 0x63677270 +#endif + + namespace ray { Status SysFsCgroupDriver::CheckCgroupv2Enabled() { FILE *fp = setmntent(mount_file_path_.c_str(), "r"); diff --git a/src/ray/common/cgroup2/sysfs_cgroup_driver.h b/src/ray/common/cgroup2/sysfs_cgroup_driver.h index de5104caeec6..ed882538c9b4 100644 --- a/src/ray/common/cgroup2/sysfs_cgroup_driver.h +++ b/src/ray/common/cgroup2/sysfs_cgroup_driver.h @@ -13,8 +13,10 @@ // limitations under the License. #pragma once -#include -#include +// TODO(#54703): SysFsCgroupDriver should not be a public target. +// It will be hidden behind a CgroupManagerFactory which will create +// an appropriate depending on configuration and platform. +// #include #include #include @@ -24,12 +26,6 @@ #include "ray/common/status.h" #include "ray/common/status_or.h" -// Used to identify if a filesystem is mounted using cgroupv2. -// See: https://docs.kernel.org/admin-guide/cgroup-v2.html#mounting -#ifndef CGROUP2_SUPER_MAGIC -#define CGROUP2_SUPER_MAGIC 0x63677270 -#endif - namespace ray { /** @@ -51,7 +47,7 @@ class SysFsCgroupDriver : public CgroupDriverInterface { * * @param mount_file_path only used for testing. */ - explicit SysFsCgroupDriver(std::string mount_file_path = MOUNTED) + explicit SysFsCgroupDriver(std::string mount_file_path = kMountFilePath) : mount_file_path_(std::move(mount_file_path)) {} ~SysFsCgroupDriver() override = default; @@ -280,5 +276,6 @@ class SysFsCgroupDriver : public CgroupDriverInterface { static constexpr std::string_view kCgroupSubtreeControlFilename = "cgroup.subtree_control"; static constexpr std::string_view kCgroupControllersFilename = "cgroup.controllers"; + static inline std::string kMountFilePath = "/mnt/mtab"; }; } // namespace ray From 029991282fe118f5c0c5f8ec5249349be3f26262 Mon Sep 17 00:00:00 2001 From: israbbani Date: Thu, 11 Sep 2025 21:46:33 -0700 Subject: [PATCH 2/5] fixing linting error Signed-off-by: israbbani --- src/ray/common/cgroup2/sysfs_cgroup_driver.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ray/common/cgroup2/sysfs_cgroup_driver.cc b/src/ray/common/cgroup2/sysfs_cgroup_driver.cc index 5f121857f5c5..afa5be6ce544 100644 --- a/src/ray/common/cgroup2/sysfs_cgroup_driver.cc +++ b/src/ray/common/cgroup2/sysfs_cgroup_driver.cc @@ -43,7 +43,6 @@ #define CGROUP2_SUPER_MAGIC 0x63677270 #endif - namespace ray { Status SysFsCgroupDriver::CheckCgroupv2Enabled() { FILE *fp = setmntent(mount_file_path_.c_str(), "r"); From 1a6bf2b0a4413fb30f2538da69d6ef5154b4e061 Mon Sep 17 00:00:00 2001 From: israbbani Date: Thu, 11 Sep 2025 22:07:16 -0700 Subject: [PATCH 3/5] one more linter issue Signed-off-by: israbbani --- src/ray/common/cgroup2/BUILD.bazel | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ray/common/cgroup2/BUILD.bazel b/src/ray/common/cgroup2/BUILD.bazel index 9431d096755f..b2becaa0575b 100644 --- a/src/ray/common/cgroup2/BUILD.bazel +++ b/src/ray/common/cgroup2/BUILD.bazel @@ -14,7 +14,7 @@ ray_cc_library( }), hdrs = [ "cgroup_manager.h", - "scoped_cgroup_operation.h" + "scoped_cgroup_operation.h", ], visibility = ["//visibility:public"], deps = [ @@ -57,10 +57,10 @@ ray_cc_library( ray_cc_library( name = "sysfs_cgroup_driver", - srcs = select({ + srcs = select({ ":is_linux": ["sysfs_cgroup_driver.cc"], "//conditions:default": ["noop_sysfs_cgroup_driver.cc"], - }), + }), hdrs = [ "sysfs_cgroup_driver.h", ], @@ -74,8 +74,8 @@ ray_cc_library( "//src/ray/util:logging", "@com_google_absl//absl/strings", ], - "//conditions:default": [], - }) + "//conditions:default": [], + }), ) # Private Targets. From 83de3f45399aef4957f11e78125b01df7d4fcf2b Mon Sep 17 00:00:00 2001 From: israbbani Date: Fri, 12 Sep 2025 10:28:50 -0700 Subject: [PATCH 4/5] fixing lint error from merging master Signed-off-by: israbbani --- python/ray/util/collective/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/ray/util/collective/util.py b/python/ray/util/collective/util.py index e46d374d8f85..02221995fd60 100644 --- a/python/ray/util/collective/util.py +++ b/python/ray/util/collective/util.py @@ -1,6 +1,6 @@ """Some utility class for Collectives.""" -import logging import asyncio +import logging import ray From 57ed34d0235e34d3d2409d8a7e0ecebff21aea72 Mon Sep 17 00:00:00 2001 From: israbbani Date: Fri, 12 Sep 2025 11:01:55 -0700 Subject: [PATCH 5/5] fixing /mnt/mtab -> /etc/mtab. Removing comments about MOUNTED Signed-off-by: israbbani --- src/ray/common/cgroup2/sysfs_cgroup_driver.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/ray/common/cgroup2/sysfs_cgroup_driver.h b/src/ray/common/cgroup2/sysfs_cgroup_driver.h index ed882538c9b4..6b01fbe4886f 100644 --- a/src/ray/common/cgroup2/sysfs_cgroup_driver.h +++ b/src/ray/common/cgroup2/sysfs_cgroup_driver.h @@ -42,9 +42,6 @@ namespace ray { class SysFsCgroupDriver : public CgroupDriverInterface { public: /** - * MOUNTED is defined in mntent.h (and typically refers to /etc/mtab) - * @see https://www.gnu.org/software/libc/manual/2.24/html_node/Mount-Information.html - * * @param mount_file_path only used for testing. */ explicit SysFsCgroupDriver(std::string mount_file_path = kMountFilePath) @@ -276,6 +273,6 @@ class SysFsCgroupDriver : public CgroupDriverInterface { static constexpr std::string_view kCgroupSubtreeControlFilename = "cgroup.subtree_control"; static constexpr std::string_view kCgroupControllersFilename = "cgroup.controllers"; - static inline std::string kMountFilePath = "/mnt/mtab"; + static inline std::string kMountFilePath = "/etc/mtab"; }; } // namespace ray