[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mesos-commits
Subject:    mesos git commit: Used perf version instead of kernel version in perf::supported().
From:       bmahler () apache ! org
Date:       2015-08-31 22:48:32
Message-ID: c2c5722f10c541ae904b9f233723341e () git ! apache ! org
[Download RAW message or body]

Repository: mesos
Updated Branches:
  refs/heads/master 09e4ba2fa -> 5fff044c3


Used perf version instead of kernel version in perf::supported().

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


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

Branch: refs/heads/master
Commit: 5fff044c370bb1eb047e367de5d7b314d6b62ecc
Parents: 09e4ba2
Author: Paul Brett <paul_b@twopensource.com>
Authored: Mon Aug 31 15:31:37 2015 -0700
Committer: Benjamin Mahler <benjamin.mahler@gmail.com>
Committed: Mon Aug 31 15:48:15 2015 -0700

----------------------------------------------------------------------
 src/linux/perf.cpp | 37 +++++++++++++++++++++++++++++++------
 1 file changed, 31 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/5fff044c/src/linux/perf.cpp
----------------------------------------------------------------------
diff --git a/src/linux/perf.cpp b/src/linux/perf.cpp
index cdc5f83..56ef391 100644
--- a/src/linux/perf.cpp
+++ b/src/linux/perf.cpp
@@ -383,6 +383,21 @@ Future<hashmap<string, mesos::PerfStatistics>> sample(
 } // namespace internal {
 
 
+Future<Version> version()
+{
+  internal::Perf* perf = new internal::Perf({"--version"});
+  Future<string> future = perf->future();
+  spawn(perf, true);
+
+  return future
+    .then([=](const string& output) -> Future<Version> {
+      // Trim off the leading 'perf version ' text to convert.
+      return Version::parse(strings::remove(
+          output, "perf version ", strings::PREFIX));
+    });
+};
+
+
 Future<mesos::PerfStatistics> sample(
     const set<string>& events,
     pid_t pid,
@@ -450,14 +465,24 @@ bool valid(const set<string>& events)
 
 bool supported()
 {
-  // Require Linux kernel version >= 2.6.38 for "-x" and >= 2.6.39 for
-  // "--cgroup"
-  Try<Version> release = os::release();
+  // Require perf version >= 2.6.39 to support cgroups and formatting.
+  Future<Version> version = perf::version();
+
+  // If perf does not respond in a reasonable time, mark as unsupported.
+  version.await(Seconds(5));
+
+  if (!version.isReady()) {
+    if (version.isFailed()) {
+      LOG(ERROR) << "Failed to get perf version: " << version.failure();
+    } else {
+      LOG(ERROR) << "Failed to get perf version: timeout of 5secs exceeded";
+    }
 
-  // This is not expected to ever be an Error.
-  CHECK_SOME(release);
+    version.discard();
+    return false;
+  }
 
-  return release.get() >= Version(2, 6, 39);
+  return version.get() >= Version(2, 6, 39);
 }
 
 

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic