X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=include%2Flinux%2Fcgroup.h;h=bbf4d89b56a8ccab699fe8342c778ca780a22d1b;hb=e14880f7bb7e0dc0933af304998371dd543ceb40;hp=4dfcd0e1b73e290483931caa7cd68d47da6b1e37;hpb=b414dc09a31d41d696093a4cce9fb2853a5ecd4e;p=platform%2Fadaptation%2Frenesas_rcar%2Frenesas_kernel.git diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h index 4dfcd0e..bbf4d89 100644 --- a/include/linux/cgroup.h +++ b/include/linux/cgroup.h @@ -720,6 +720,24 @@ static inline struct cgroup* task_cgroup(struct task_struct *task, return task_subsys_state(task, subsys_id)->cgroup; } +/** + * cgroup_from_id - lookup cgroup by id + * @ss: cgroup subsys to be looked into + * @id: the cgroup id + * + * Returns the cgroup if there's valid one with @id, otherwise returns NULL. + * Should be called under rcu_read_lock(). + */ +static inline struct cgroup *cgroup_from_id(struct cgroup_subsys *ss, int id) +{ +#ifdef CONFIG_PROVE_RCU + rcu_lockdep_assert(rcu_read_lock_held() || + lockdep_is_held(&cgroup_mutex), + "cgroup_from_id() needs proper protection"); +#endif + return idr_find(&ss->root->cgroup_idr, id); +} + struct cgroup *cgroup_next_sibling(struct cgroup *pos); /**