Used low cpu.shares for revocable containers.

Review: https://reviews.apache.org/r/36411


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/b5dfddf5
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/b5dfddf5
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/b5dfddf5

Branch: refs/heads/master
Commit: b5dfddf5bdf73156b079e7de14a736d6a86f9073
Parents: aaa3588
Author: Jie Yu <[email protected]>
Authored: Fri Jul 10 16:18:46 2015 -0700
Committer: Jie Yu <[email protected]>
Committed: Thu Jul 16 16:57:40 2015 -0700

----------------------------------------------------------------------
 .../containerizer/isolators/cgroups/constants.hpp     |  1 +
 .../containerizer/isolators/cgroups/cpushare.cpp      | 14 ++++++++++++--
 2 files changed, 13 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/b5dfddf5/src/slave/containerizer/isolators/cgroups/constants.hpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/isolators/cgroups/constants.hpp 
b/src/slave/containerizer/isolators/cgroups/constants.hpp
index 31df7df..db9dde0 100644
--- a/src/slave/containerizer/isolators/cgroups/constants.hpp
+++ b/src/slave/containerizer/isolators/cgroups/constants.hpp
@@ -28,6 +28,7 @@ namespace slave {
 
 // CPU subsystem constants.
 const uint64_t CPU_SHARES_PER_CPU = 1024;
+const uint64_t CPU_SHARES_PER_CPU_REVOCABLE = 10;
 const uint64_t MIN_CPU_SHARES = 2; // Linux constant.
 const Duration CPU_CFS_PERIOD = Milliseconds(100); // Linux default.
 const Duration MIN_CPU_CFS_QUOTA = Milliseconds(1);

http://git-wip-us.apache.org/repos/asf/mesos/blob/b5dfddf5/src/slave/containerizer/isolators/cgroups/cpushare.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/isolators/cgroups/cpushare.cpp 
b/src/slave/containerizer/isolators/cgroups/cpushare.cpp
index f56e97d..45ee2fc 100644
--- a/src/slave/containerizer/isolators/cgroups/cpushare.cpp
+++ b/src/slave/containerizer/isolators/cgroups/cpushare.cpp
@@ -394,8 +394,18 @@ Future<Nothing> CgroupsCpushareIsolatorProcess::update(
   double cpus = resources.cpus().get();
 
   // Always set cpu.shares.
-  uint64_t shares =
-    std::max((uint64_t) (CPU_SHARES_PER_CPU * cpus), MIN_CPU_SHARES);
+  uint64_t shares;
+
+  if (flags.revocable_cpu_low_priority &&
+      resources.revocable().cpus().isSome()) {
+    shares = std::max(
+        (uint64_t) (CPU_SHARES_PER_CPU_REVOCABLE * cpus),
+        MIN_CPU_SHARES);
+  } else {
+    shares = std::max(
+        (uint64_t) (CPU_SHARES_PER_CPU * cpus),
+        MIN_CPU_SHARES);
+  }
 
   Try<Nothing> write = cgroups::cpu::shares(
       hierarchy.get(),

Reply via email to