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/26 02:14:37 UTC
[1/2] git commit: Add check for perf support.
Repository: mesos
Updated Branches:
refs/heads/master e878c74fb -> 03284a323
Add check for perf support.
Review: https://reviews.apache.org/r/22898
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/03284a32
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/03284a32
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/03284a32
Branch: refs/heads/master
Commit: 03284a3233cc39643914e483b1d0f69221537a37
Parents: 50e1b12
Author: Ian Downes <id...@twitter.com>
Authored: Tue Jun 17 17:04:59 2014 -0700
Committer: Ian Downes <id...@twitter.com>
Committed: Wed Jun 25 17:13:47 2014 -0700
----------------------------------------------------------------------
src/linux/perf.cpp | 26 ++++++++++++++++++++
src/linux/perf.hpp | 5 ++++
.../isolators/cgroups/perf_event.cpp | 4 +++
3 files changed, 35 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/03284a32/src/linux/perf.cpp
----------------------------------------------------------------------
diff --git a/src/linux/perf.cpp b/src/linux/perf.cpp
index fc5acf4..c6dc120 100644
--- a/src/linux/perf.cpp
+++ b/src/linux/perf.cpp
@@ -285,6 +285,10 @@ Future<mesos::PerfStatistics> sample(
const set<pid_t>& pids,
const Duration& duration)
{
+ if (!supported()) {
+ return Failure("Perf is not supported");
+ }
+
const string command = internal::command(events, pids, duration);
internal::PerfSampler* sampler = new internal::PerfSampler(command, duration);
Future<hashmap<string, mesos::PerfStatistics> > future = sampler->future();
@@ -311,6 +315,10 @@ Future<hashmap<string, mesos::PerfStatistics> > sample(
const set<string>& cgroups,
const Duration& duration)
{
+ if (!supported()) {
+ return Failure("Perf is not supported");
+ }
+
const string command = internal::command(events, cgroups, duration);
internal::PerfSampler* sampler = new internal::PerfSampler(command, duration);
Future<hashmap<string, mesos::PerfStatistics> > future = sampler->future();
@@ -334,6 +342,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<os::Release> release = os::release();
+
+ // This is not expected to ever be an Error.
+ CHECK_SOME(release);
+
+ os::Release required;
+ required.version = 2;
+ required.major = 6;
+ required.minor = 39;
+
+ return required <= release.get();
+}
+
+
Try<hashmap<string, mesos::PerfStatistics> > parse(const string& output)
{
hashmap<string, mesos::PerfStatistics> statistics;
http://git-wip-us.apache.org/repos/asf/mesos/blob/03284a32/src/linux/perf.hpp
----------------------------------------------------------------------
diff --git a/src/linux/perf.hpp b/src/linux/perf.hpp
index 0d510c5..dd9299c 100644
--- a/src/linux/perf.hpp
+++ b/src/linux/perf.hpp
@@ -69,6 +69,11 @@ process::Future<mesos::PerfStatistics> sample(
bool valid(const std::set<std::string>& events);
+// Returns whether perf is supported on this host. Returns false if
+// the kernel is too old (requires >= 2.6.39).
+bool supported();
+
+
// Note: Exposed for testing purposes.
Try<hashmap<std::string, mesos::PerfStatistics> > parse(
const std::string& output);
http://git-wip-us.apache.org/repos/asf/mesos/blob/03284a32/src/slave/containerizer/isolators/cgroups/perf_event.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/isolators/cgroups/perf_event.cpp b/src/slave/containerizer/isolators/cgroups/perf_event.cpp
index 1bd5dfa..6f65b72 100644
--- a/src/slave/containerizer/isolators/cgroups/perf_event.cpp
+++ b/src/slave/containerizer/isolators/cgroups/perf_event.cpp
@@ -65,6 +65,10 @@ Try<Isolator*> CgroupsPerfEventIsolatorProcess::create(const Flags& flags)
{
LOG(INFO) << "Creating PerfEvent isolator";
+ if (!perf::supported()) {
+ return Error("Perf is not supported");
+ }
+
if (flags.perf_duration > flags.perf_interval) {
return Error("Sampling perf for duration (" +
stringify(flags.perf_duration) +
[2/2] git commit: Add some relation operators to os::Release
Posted by id...@apache.org.
Add some relation operators to os::Release
Review: https://reviews.apache.org/r/22897
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/50e1b120
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/50e1b120
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/50e1b120
Branch: refs/heads/master
Commit: 50e1b120578e1626daba630515218fea27acc340
Parents: e878c74
Author: Ian Downes <id...@twitter.com>
Authored: Mon Jun 23 16:12:52 2014 -0700
Committer: Ian Downes <id...@twitter.com>
Committed: Wed Jun 25 17:13:47 2014 -0700
----------------------------------------------------------------------
.../3rdparty/stout/include/stout/os.hpp | 24 ++++++++++++++++++++
1 file changed, 24 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/50e1b120/3rdparty/libprocess/3rdparty/stout/include/stout/os.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/os.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/os.hpp
index 0529f88..0825172 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/os.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/os.hpp
@@ -1129,6 +1129,30 @@ inline Try<std::string> sysname()
// The OS release level.
struct Release
{
+ bool operator == (const Release& other)
+ {
+ return version == other.version &&
+ major == other.major &&
+ minor == other.minor;
+ }
+
+ bool operator < (const Release& other)
+ {
+ // Lexicographic ordering.
+ if (version != other.version) {
+ return version < other.version;
+ } else if (major != other.major) {
+ return major < other.major;
+ } else {
+ return minor < other.minor;
+ }
+ }
+
+ bool operator <= (const Release& other)
+ {
+ return *this < other || *this == other;
+ }
+
int version;
int major;
int minor;