aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/cpuset.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2013-08-08 20:11:23 -0400
committerTejun Heo <tj@kernel.org>2013-08-08 20:11:23 -0400
commita7c6d554aa01236ac2a9f851ab0f75704f76dfa2 (patch)
treefe62d07283a589daa39f843deaefafd11c572b84 /kernel/cpuset.c
parent72c97e54e0f043d33b246d7460ae0a36c4b8c643 (diff)
cgroup: add/update accessors which obtain subsys specific data from css
css (cgroup_subsys_state) is usually embedded in a subsys specific data structure. Subsystems either use container_of() directly to cast from css to such data structure or has an accessor function wrapping such cast. As cgroup as whole is moving towards using css as the main interface handle, add and update such accessors to ease dealing with css's. All accessors explicitly handle NULL input and return NULL in those cases. While this looks like an extra branch in the code, as all controllers specific data structures have css as the first field, the casting doesn't involve any offsetting and the compiler can trivially optimize out the branch. * blkio, freezer, cpuset, cpu, cpuacct and net_cls didn't have such accessor. Added. * memory, hugetlb and devices already had one but didn't explicitly handle NULL input. Updated. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Li Zefan <lizefan@huawei.com>
Diffstat (limited to 'kernel/cpuset.c')
-rw-r--r--kernel/cpuset.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index f7371341d42a..6e9cbdde25bd 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -114,18 +114,21 @@ struct cpuset {
114 int relax_domain_level; 114 int relax_domain_level;
115}; 115};
116 116
117static inline struct cpuset *css_cs(struct cgroup_subsys_state *css)
118{
119 return css ? container_of(css, struct cpuset, css) : NULL;
120}
121
117/* Retrieve the cpuset for a cgroup */ 122/* Retrieve the cpuset for a cgroup */
118static inline struct cpuset *cgroup_cs(struct cgroup *cgrp) 123static inline struct cpuset *cgroup_cs(struct cgroup *cgrp)
119{ 124{
120 return container_of(cgroup_css(cgrp, cpuset_subsys_id), 125 return css_cs(cgroup_css(cgrp, cpuset_subsys_id));
121 struct cpuset, css);
122} 126}
123 127
124/* Retrieve the cpuset for a task */ 128/* Retrieve the cpuset for a task */
125static inline struct cpuset *task_cs(struct task_struct *task) 129static inline struct cpuset *task_cs(struct task_struct *task)
126{ 130{
127 return container_of(task_css(task, cpuset_subsys_id), 131 return css_cs(task_css(task, cpuset_subsys_id));
128 struct cpuset, css);
129} 132}
130 133
131static inline struct cpuset *parent_cs(struct cpuset *cs) 134static inline struct cpuset *parent_cs(struct cpuset *cs)