aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLi Zefan <lizefan@huawei.com>2013-08-18 22:05:24 -0400
committerTejun Heo <tj@kernel.org>2013-08-19 09:52:18 -0400
commit1cb650b91ba582f6737457b7d22e368585596d2c (patch)
tree1a3d8d4a219dcca229dcc6dc47876091ef0f8438
parent930913a31289202d232186b82854b26d7fb7cf4d (diff)
cgroup: change cgroup_from_id() to css_from_id()
Now we want cgroup core to always provide the css to use to the subsystems, so change this API to css_from_id(). Uninline css_from_id(), because it's getting bigger and cgroup_css() has been unexported. While at it, remove the #ifdef, and shuffle the order of the args. Signed-off-by: Li Zefan <lizefan@huawei.com> Signed-off-by: Tejun Heo <tj@kernel.org>
-rw-r--r--include/linux/cgroup.h20
-rw-r--r--kernel/cgroup.c22
2 files changed, 24 insertions, 18 deletions
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index c24bd0b9f93a..b685955d4b29 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -741,27 +741,11 @@ static inline struct cgroup *task_cgroup(struct task_struct *task,
741 return task_css(task, subsys_id)->cgroup; 741 return task_css(task, subsys_id)->cgroup;
742} 742}
743 743
744/**
745 * cgroup_from_id - lookup cgroup by id
746 * @ss: cgroup subsys to be looked into
747 * @id: the cgroup id
748 *
749 * Returns the cgroup if there's valid one with @id, otherwise returns NULL.
750 * Should be called under rcu_read_lock().
751 */
752static inline struct cgroup *cgroup_from_id(struct cgroup_subsys *ss, int id)
753{
754#ifdef CONFIG_PROVE_RCU
755 rcu_lockdep_assert(rcu_read_lock_held() ||
756 lockdep_is_held(&cgroup_mutex),
757 "cgroup_from_id() needs proper protection");
758#endif
759 return idr_find(&ss->root->cgroup_idr, id);
760}
761
762struct cgroup_subsys_state *css_next_child(struct cgroup_subsys_state *pos, 744struct cgroup_subsys_state *css_next_child(struct cgroup_subsys_state *pos,
763 struct cgroup_subsys_state *parent); 745 struct cgroup_subsys_state *parent);
764 746
747struct cgroup_subsys_state *css_from_id(int id, struct cgroup_subsys *ss);
748
765/** 749/**
766 * css_for_each_child - iterate through children of a css 750 * css_for_each_child - iterate through children of a css
767 * @pos: the css * to use as the loop cursor 751 * @pos: the css * to use as the loop cursor
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index b69b572131e5..ff7d642a070a 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -5717,6 +5717,28 @@ struct cgroup_subsys_state *cgroup_css_from_dir(struct file *f, int id)
5717 return css ? css : ERR_PTR(-ENOENT); 5717 return css ? css : ERR_PTR(-ENOENT);
5718} 5718}
5719 5719
5720/**
5721 * css_from_id - lookup css by id
5722 * @id: the cgroup id
5723 * @ss: cgroup subsys to be looked into
5724 *
5725 * Returns the css if there's valid one with @id, otherwise returns NULL.
5726 * Should be called under rcu_read_lock().
5727 */
5728struct cgroup_subsys_state *css_from_id(int id, struct cgroup_subsys *ss)
5729{
5730 struct cgroup *cgrp;
5731
5732 rcu_lockdep_assert(rcu_read_lock_held() ||
5733 lockdep_is_held(&cgroup_mutex),
5734 "css_from_id() needs proper protection");
5735
5736 cgrp = idr_find(&ss->root->cgroup_idr, id);
5737 if (cgrp)
5738 return cgroup_css(cgrp, ss->subsys_id);
5739 return NULL;
5740}
5741
5720#ifdef CONFIG_CGROUP_DEBUG 5742#ifdef CONFIG_CGROUP_DEBUG
5721static struct cgroup_subsys_state * 5743static struct cgroup_subsys_state *
5722debug_css_alloc(struct cgroup_subsys_state *parent_css) 5744debug_css_alloc(struct cgroup_subsys_state *parent_css)