diff options
Diffstat (limited to 'kernel/cgroup.c')
-rw-r--r-- | kernel/cgroup.c | 22 |
1 files changed, 22 insertions, 0 deletions
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 | */ | ||
5728 | struct 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 |
5721 | static struct cgroup_subsys_state * | 5743 | static struct cgroup_subsys_state * |
5722 | debug_css_alloc(struct cgroup_subsys_state *parent_css) | 5744 | debug_css_alloc(struct cgroup_subsys_state *parent_css) |