Added named cgroup hierarchy support.

This patch add a helper to get the cgroup associated with the given
pid for a named cgroup hierarchy.

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


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

Branch: refs/heads/master
Commit: 2ece53c39a3e791f6892c4a734b6d3187f184190
Parents: 0499025
Author: Jie Yu <yujie....@gmail.com>
Authored: Thu Oct 5 20:49:20 2017 -0700
Committer: Jie Yu <yujie....@gmail.com>
Committed: Fri Feb 9 17:04:04 2018 -0800

----------------------------------------------------------------------
 src/linux/cgroups.cpp | 10 ++++++++++
 src/linux/cgroups.hpp | 12 ++++++++++++
 2 files changed, 22 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/2ece53c3/src/linux/cgroups.cpp
----------------------------------------------------------------------
diff --git a/src/linux/cgroups.cpp b/src/linux/cgroups.cpp
index cdd0f40..ed22c45 100644
--- a/src/linux/cgroups.cpp
+++ b/src/linux/cgroups.cpp
@@ -3131,4 +3131,14 @@ Try<Nothing> classid(
 
 } // namespace net_cls {
 
+
+namespace named {
+
+Result<string> cgroup(const string& hierarchyName, pid_t pid)
+{
+  return internal::cgroup(pid, "name=" + hierarchyName);
+}
+
+} // namespace named {
+
 } // namespace cgroups {

http://git-wip-us.apache.org/repos/asf/mesos/blob/2ece53c3/src/linux/cgroups.hpp
----------------------------------------------------------------------
diff --git a/src/linux/cgroups.hpp b/src/linux/cgroups.hpp
index 154e5b6..6a6f0e6 100644
--- a/src/linux/cgroups.hpp
+++ b/src/linux/cgroups.hpp
@@ -999,6 +999,18 @@ Try<Nothing> classid(
 
 } // namespace net_cls {
 
+
+// Named hierarchy.
+namespace named {
+
+// Returns the cgroup that the specified pid is a member of within the
+// given named hierarchy is mounted or None if the named hierarchy is
+// not mounted or the pid is not a member of a cgroup.
+Result<std::string> cgroup(const std::string& hierarchyName, pid_t pid);
+
+} // namespace named {
+
+
 } // namespace cgroups {
 
 namespace std {

Reply via email to