cgroup: add subsystem pointer to cgroup_subsys_state
authorTejun Heo <tj@kernel.org>
Fri, 9 Aug 2013 00:11:22 +0000 (20:11 -0400)
committerTejun Heo <tj@kernel.org>
Fri, 9 Aug 2013 00:11:22 +0000 (20:11 -0400)
Currently, given a cgroup_subsys_state, there's no way to find out
which subsystem the css is for, which we'll need to convert the cgroup
controller API to primarily use @css instead of @cgroup.  This patch
adds cgroup_subsys_state->ss which points to the subsystem the @css
belongs to.

While at it, remove the comment about accessing @css->cgroup to
determine the hierarchy.  cgroup core will provide API to traverse
hierarchy of css'es and we don't want subsystems to directly walk
cgroup hierarchies anymore.

Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Li Zefan <lizefan@huawei.com>
include/linux/cgroup.h
kernel/cgroup.c

index 552c5feef733c4eadae9a50f38412620beaf99b8..821678aae4db607aa0bcc539107bbf6c441597a7 100644 (file)
@@ -66,13 +66,12 @@ enum cgroup_subsys_id {
 
 /* Per-subsystem/per-cgroup state maintained by the system. */
 struct cgroup_subsys_state {
-       /*
-        * The cgroup that this subsystem is attached to. Useful
-        * for subsystems that want to know about the cgroup
-        * hierarchy structure
-        */
+       /* the cgroup that this css is attached to */
        struct cgroup *cgroup;
 
+       /* the cgroup subsystem that this css is attached to */
+       struct cgroup_subsys *ss;
+
        /* reference count - access via css_[try]get() and css_put() */
        struct percpu_ref refcnt;
 
index 0b3caa3220cbe91836a5dd72d3a7f3c60c6afd4d..4234428f1014dc8e3800a48c6883a316d0880938 100644 (file)
@@ -4186,6 +4186,7 @@ static void init_cgroup_css(struct cgroup_subsys_state *css,
                               struct cgroup *cgrp)
 {
        css->cgroup = cgrp;
+       css->ss = ss;
        css->flags = 0;
        css->id = NULL;
        if (cgrp == cgroup_dummy_top)