lkml.org 
[lkml]   [2014]   [Apr]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 1/4] cgroup: introduce helper css_to_id()
Date
This is a prepared patch for converting from per-cgroup id to
per-subsystem id.

Some subsystems dereference the per-cgrpu id directly, but this is
implementation-specific, so it should be transparent for subsystems.

Use this accessor instead.

Signed-off-by: Jianyu Zhan <nasa4836@gmail.com>
---
include/linux/cgroup.h | 1 +
kernel/cgroup.c | 11 +++++++++++
2 files changed, 12 insertions(+)

diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index 4b38e2d..de31b2a 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -754,6 +754,7 @@ struct cgroup_subsys_state *css_next_child(struct cgroup_subsys_state *pos,
struct cgroup_subsys_state *parent);

struct cgroup_subsys_state *css_from_id(int id, struct cgroup_subsys *ss);
+int css_to_id(struct cgroup_subsys_state *css);

/**
* css_for_each_child - iterate through children of a css
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 930569c..80c1cf3 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -5153,6 +5153,17 @@ struct cgroup_subsys_state *css_tryget_from_dir(struct dentry *dentry,
}

/**
+ * css_to_id - get the id of a css
+ * @css: the css of interest
+ *
+ * Return the corresponding id for the @css.
+ */
+int css_to_id(struct cgroup_subsys_state *css)
+{
+ return css->cgroup->id;
+}
+
+/**
* css_from_id - lookup css by id
* @id: the cgroup id
* @ss: cgroup subsys to be looked into
--
2.0.0-rc0


\
 
 \ /
  Last update: 2014-04-22 09:01    [W:0.101 / U:0.056 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site