You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2012/08/08 00:08:19 UTC
svn commit: r1370563 -
/incubator/mesos/trunk/src/slave/cgroups_isolation_module.cpp
Author: benh
Date: Tue Aug 7 22:08:19 2012
New Revision: 1370563
URL: http://svn.apache.org/viewvc?rev=1370563&view=rev
Log:
Fixes the problem of cpuset.cpus and cpuset.mems in cgroups isolation
module (contributed by Jie Yu, https://reviews.apache.org/r/6452).
Modified:
incubator/mesos/trunk/src/slave/cgroups_isolation_module.cpp
Modified: incubator/mesos/trunk/src/slave/cgroups_isolation_module.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/slave/cgroups_isolation_module.cpp?rev=1370563&r1=1370562&r2=1370563&view=diff
==============================================================================
--- incubator/mesos/trunk/src/slave/cgroups_isolation_module.cpp (original)
+++ incubator/mesos/trunk/src/slave/cgroups_isolation_module.cpp Tue Aug 7 22:08:19 2012
@@ -95,11 +95,14 @@ void CgroupsIsolationModule::initialize(
// Configure cgroups hierarchy root path.
hierarchy = flags.cgroups_hierarchy_root;
+ LOG(INFO) << "Using " << hierarchy << " as cgroups hierarchy root";
+
// Configure required/optional subsystems.
hashset<std::string> requiredSubsystems;
hashset<std::string> optionalSubsystems;
requiredSubsystems.insert("cpu");
+ requiredSubsystems.insert("cpuset");
requiredSubsystems.insert("memory");
requiredSubsystems.insert("freezer");
@@ -218,14 +221,15 @@ void CgroupsIsolationModule::launchExecu
const ExecutorID& executorId = executorInfo.executor_id();
+ // Register the cgroup information.
+ registerCgroupInfo(frameworkId, executorId);
+
LOG(INFO) << "Launching " << executorId
<< " (" << executorInfo.command().value() << ")"
<< " in " << directory
<< " with resources " << resources
- << " for framework " << frameworkId;
-
- // Register the cgroup information.
- registerCgroupInfo(frameworkId, executorId);
+ << " for framework " << frameworkId
+ << " in cgroup " << getCgroupName(frameworkId, executorId);
// Create a new cgroup for the executor.
Try<bool> create =
@@ -236,6 +240,51 @@ void CgroupsIsolationModule::launchExecu
<< ": " << create.error();
}
+ // Copy the values of cpuset.cpus and cpuset.mems from the cgroups hierarchy
+ // root. This is necessary because the newly created cgroup does not have
+ // these two values set.
+ // TODO(jieyu): Think about other ways that do not rely on the values from the
+ // cgroups hierarchy root.
+ Try<std::string> rootCpusetCpus =
+ cgroups::readControl(hierarchy,
+ "/",
+ "cpuset.cpus");
+ if (rootCpusetCpus.isError()) {
+ LOG(FATAL) << "Failed to get cpuset.cpus in hierarchy root: "
+ << rootCpusetCpus.error();
+ }
+
+ Try<std::string> rootCpusetMems =
+ cgroups::readControl(hierarchy,
+ "/",
+ "cpuset.mems");
+ if (rootCpusetMems.isError()) {
+ LOG(FATAL) << "Failed to get cpuset.mems in hierarchy root: "
+ << rootCpusetMems.error();
+ }
+
+ Try<bool> setCpusetCpus =
+ cgroups::writeControl(hierarchy,
+ getCgroupName(frameworkId, executorId),
+ "cpuset.cpus",
+ rootCpusetCpus.get());
+ if (setCpusetCpus.isError()) {
+ LOG(FATAL) << "Failed to write cpuset.cpus for executor "
+ << executorId << " of framework " << frameworkId
+ << ": " << setCpusetCpus.error();
+ }
+
+ Try<bool> setCpusetMems =
+ cgroups::writeControl(hierarchy,
+ getCgroupName(frameworkId, executorId),
+ "cpuset.mems",
+ rootCpusetMems.get());
+ if (setCpusetMems.isError()) {
+ LOG(FATAL) << "Failed to write cpuset.mems for executor "
+ << executorId << " of framework " << frameworkId
+ << ": " << setCpusetMems.error();
+ }
+
// Setup the initial resource constrains.
resourcesChanged(frameworkId, executorId, resources);