You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by id...@apache.org on 2014/06/17 21:27:38 UTC

git commit: Only report cpu.stat values if CFS quota is enabled.

Repository: mesos
Updated Branches:
  refs/heads/master 18d737cdd -> 57a856686


Only report cpu.stat values if CFS quota is enabled.

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


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

Branch: refs/heads/master
Commit: 57a856686811cd9e67bd7a89e809c041e0a8b2e8
Parents: 18d737c
Author: Ian Downes <id...@twitter.com>
Authored: Thu Jun 12 17:07:50 2014 -0700
Committer: Ian Downes <id...@twitter.com>
Committed: Tue Jun 17 11:51:43 2014 -0700

----------------------------------------------------------------------
 .../isolators/cgroups/cpushare.cpp              | 36 +++++++++++---------
 1 file changed, 19 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/57a85668/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 ca1b421..3265a80 100644
--- a/src/slave/containerizer/isolators/cgroups/cpushare.cpp
+++ b/src/slave/containerizer/isolators/cgroups/cpushare.cpp
@@ -406,27 +406,29 @@ Future<ResourceStatistics> CgroupsCpushareIsolatorProcess::usage(
     result.set_cpus_system_time_secs((double) system.get() / (double) ticks);
   }
 
-  // Add the cpu.stat information.
-  stat = cgroups::stat(hierarchies["cpu"], info->cgroup, "cpu.stat");
+  // Add the cpu.stat information only if CFS is enabled.
+  if (flags.cgroups_enable_cfs) {
+    stat = cgroups::stat(hierarchies["cpu"], info->cgroup, "cpu.stat");
 
-  if (stat.isError()) {
-    return Failure("Failed to read cpu.stat: " + stat.error());
-  }
+    if (stat.isError()) {
+      return Failure("Failed to read cpu.stat: " + stat.error());
+    }
 
-  Option<uint64_t> nr_periods = stat.get().get("nr_periods");
-  if (nr_periods.isSome()) {
-    result.set_cpus_nr_periods(nr_periods.get());
-  }
+    Option<uint64_t> nr_periods = stat.get().get("nr_periods");
+    if (nr_periods.isSome()) {
+      result.set_cpus_nr_periods(nr_periods.get());
+    }
 
-  Option<uint64_t> nr_throttled = stat.get().get("nr_throttled");
-  if (nr_throttled.isSome()) {
-    result.set_cpus_nr_throttled(nr_throttled.get());
-  }
+    Option<uint64_t> nr_throttled = stat.get().get("nr_throttled");
+    if (nr_throttled.isSome()) {
+      result.set_cpus_nr_throttled(nr_throttled.get());
+    }
 
-  Option<uint64_t> throttled_time = stat.get().get("throttled_time");
-  if (throttled_time.isSome()) {
-    result.set_cpus_throttled_time_secs(
-        Nanoseconds(throttled_time.get()).secs());
+    Option<uint64_t> throttled_time = stat.get().get("throttled_time");
+    if (throttled_time.isSome()) {
+      result.set_cpus_throttled_time_secs(
+          Nanoseconds(throttled_time.get()).secs());
+    }
   }
 
   return result;