This is an automated email from the ASF dual-hosted git repository.

bmahler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git

commit a127cb42e70f8be06afe997fce6307ac74aa71bc
Author: Jason Zhou <[email protected]>
AuthorDate: Thu Aug 8 13:14:22 2024 -0400

    [cpuset] Introduce the CpusetControllerProcess
    
    Hosts correctly configured for cgroups v2 and provide cgroups/cpuset
    in the isolation flag and cpuset in the agent_subsystems flag
    will use this controller.
    
    Review: https://reviews.apache.org/r/75153
---
 src/CMakeLists.txt                                 |  1 +
 src/Makefile.am                                    |  2 +
 .../mesos/isolators/cgroups2/cgroups2.cpp          |  2 +
 .../mesos/isolators/cgroups2/constants.hpp         |  1 +
 .../isolators/cgroups2/controllers/cpuset.cpp      | 49 ++++++++++++++++++++++
 .../isolators/cgroups2/controllers/cpuset.hpp      | 46 ++++++++++++++++++++
 6 files changed, 101 insertions(+)

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index e753ddd21..865daa2fa 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -353,6 +353,7 @@ set(LINUX_SRC
   slave/containerizer/mesos/isolators/cgroups2/controllers/perf_event.cpp
   slave/containerizer/mesos/isolators/cgroups2/controllers/io.cpp
   slave/containerizer/mesos/isolators/cgroups2/controllers/hugetlb.cpp
+  slave/containerizer/mesos/isolators/cgroups2/controllers/cpuset.cpp
   slave/containerizer/device_manager/device_manager.cpp)
 
 if (ENABLE_XFS_DISK_ISOLATOR)
diff --git a/src/Makefile.am b/src/Makefile.am
index 497a89add..10169fe00 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1506,6 +1506,8 @@ MESOS_LINUX_FILES =                                       
                                \
   slave/containerizer/mesos/isolators/cgroups2/controllers/io.hpp    \
   slave/containerizer/mesos/isolators/cgroups2/controllers/hugetlb.cpp    \
   slave/containerizer/mesos/isolators/cgroups2/controllers/hugetlb.hpp    \
+  slave/containerizer/mesos/isolators/cgroups2/controllers/cpuset.cpp    \
+  slave/containerizer/mesos/isolators/cgroups2/controllers/cpuset.hpp    \
   slave/containerizer/device_manager/device_manager.cpp    \
   slave/containerizer/device_manager/device_manager.hpp    \
   slave/containerizer/device_manager/state.hpp
diff --git a/src/slave/containerizer/mesos/isolators/cgroups2/cgroups2.cpp 
b/src/slave/containerizer/mesos/isolators/cgroups2/cgroups2.cpp
index 71c80a23b..6434e4533 100644
--- a/src/slave/containerizer/mesos/isolators/cgroups2/cgroups2.cpp
+++ b/src/slave/containerizer/mesos/isolators/cgroups2/cgroups2.cpp
@@ -25,6 +25,7 @@
 #include "slave/containerizer/mesos/isolators/cgroups2/controllers/devices.hpp"
 #include "slave/containerizer/mesos/isolators/cgroups2/controllers/io.hpp"
 #include "slave/containerizer/mesos/isolators/cgroups2/controllers/hugetlb.hpp"
+#include "slave/containerizer/mesos/isolators/cgroups2/controllers/cpuset.hpp"
 
 #include <set>
 #include <string>
@@ -87,6 +88,7 @@ Try<Isolator*> Cgroups2IsolatorProcess::create(
     {"perf_event", &PerfEventControllerProcess::create},
     {"io", &IoControllerProcess::create}
     {"hugetlb", &HugetlbControllerProcess::create}
+    {"cpuset", &CpusetControllerProcess::create}
   };
 
   hashmap<string, Try<Owned<ControllerProcess>>(*)(
diff --git a/src/slave/containerizer/mesos/isolators/cgroups2/constants.hpp 
b/src/slave/containerizer/mesos/isolators/cgroups2/constants.hpp
index dcd82fd5f..9d7fc5749 100644
--- a/src/slave/containerizer/mesos/isolators/cgroups2/constants.hpp
+++ b/src/slave/containerizer/mesos/isolators/cgroups2/constants.hpp
@@ -42,6 +42,7 @@ const std::string CGROUPS2_CONTROLLER_PERF_EVENT_NAME = 
"perf_event";
 const std::string CGROUPS2_CONTROLLER_DEVICES_NAME = "devices";
 const std::string CGROUPS2_CONTROLLER_IO_NAME = "io";
 const std::string CGROUPS2_CONTROLLER_HUGETLB_NAME = "hugetlb";
+const std::string CGROUPS2_CONTROLLER_CPUSET_NAME = "cpuset";
 
 } // namespace slave {
 } // namespace internal {
diff --git 
a/src/slave/containerizer/mesos/isolators/cgroups2/controllers/cpuset.cpp 
b/src/slave/containerizer/mesos/isolators/cgroups2/controllers/cpuset.cpp
new file mode 100644
index 000000000..562e6d41f
--- /dev/null
+++ b/src/slave/containerizer/mesos/isolators/cgroups2/controllers/cpuset.cpp
@@ -0,0 +1,49 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you 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 <process/id.hpp>
+
+#include "slave/containerizer/mesos/isolators/cgroups2/controllers/cpuset.hpp"
+#include "slave/containerizer/mesos/isolators/cgroups2/constants.hpp"
+
+using std::string;
+
+using process::Owned;
+
+namespace mesos {
+namespace internal {
+namespace slave {
+
+Try<Owned<ControllerProcess>> CpusetControllerProcess::create(const Flags& 
flags)
+{
+  return Owned<ControllerProcess>(new CpusetControllerProcess(flags));
+}
+
+
+CpusetControllerProcess::CpusetControllerProcess(const Flags& _flags)
+  : ProcessBase(process::ID::generate("cgroups-v2-cpuset-controller")),
+    ControllerProcess(_flags) {}
+
+
+string CpusetControllerProcess::name() const
+{
+  return CGROUPS2_CONTROLLER_CPUSET_NAME;
+}
+
+
+} // namespace slave {
+} // namespace internal {
+} // namespace mesos {
diff --git 
a/src/slave/containerizer/mesos/isolators/cgroups2/controllers/cpuset.hpp 
b/src/slave/containerizer/mesos/isolators/cgroups2/controllers/cpuset.hpp
new file mode 100644
index 000000000..5291ba03d
--- /dev/null
+++ b/src/slave/containerizer/mesos/isolators/cgroups2/controllers/cpuset.hpp
@@ -0,0 +1,46 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you 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.
+
+#ifndef __CPUSET_HPP__
+#define __CPUSET_HPP__
+
+#include <string>
+
+#include "slave/containerizer/mesos/isolators/cgroups2/controller.hpp"
+
+namespace mesos {
+namespace internal {
+namespace slave {
+
+class CpusetControllerProcess : public ControllerProcess
+{
+public:
+  static Try<process::Owned<ControllerProcess>> create(
+      const Flags& flags);
+
+  ~CpusetControllerProcess() override = default;
+
+  std::string name() const override;
+
+private:
+  CpusetControllerProcess(const Flags& flags);
+};
+
+} // namespace slave {
+} // namespace internal {
+} // namespace mesos {
+
+#endif // __CPUSET_HPP__

Reply via email to