aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2013-08-13 11:01:54 -0400
committerTejun Heo <tj@kernel.org>2013-08-13 11:01:54 -0400
commit0ae78e0bf10ac38ab53548e18383afc9997eca22 (patch)
tree8f3e828b1751966af779becd60a0ff432cfefc8d /include/linux
parent35ef10da65d43211f4cd7e7822cbb3becdfc0ae1 (diff)
cgroup: add cgroup_subsys_state->parent
With the planned unified hierarchy, css's (cgroup_subsys_state) will be RCU protected and allowed to be attached and detached dynamically over the course of a cgroup's lifetime. This means that css's will stay accessible after being detached from its cgroup - the matching pointer in cgroup->subsys[] cleared - for ref draining and RCU grace period. cgroup core still wants to guarantee that the parent css is never destroyed before its children and css_parent() always returns the parent regardless of the state of the child css as long as it's accessible. This patch makes css's hold onto their parents and adds css->parent so that the parent css is never detroyed before its children and can be determined without consulting the cgroups. cgroup->dummy_css is also updated to point to the parent dummy_css; however, it doesn't need to worry about object lifetime as the parent cgroup is already pinned by the child. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Li Zefan <lizefan@huawei.com>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/cgroup.h13
1 files changed, 4 insertions, 9 deletions
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index 12d66fee26f8..8a5dc91fbaad 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -75,6 +75,9 @@ struct cgroup_subsys_state {
75 /* reference count - access via css_[try]get() and css_put() */ 75 /* reference count - access via css_[try]get() and css_put() */
76 struct percpu_ref refcnt; 76 struct percpu_ref refcnt;
77 77
78 /* the parent css */
79 struct cgroup_subsys_state *parent;
80
78 unsigned long flags; 81 unsigned long flags;
79 /* ID for this css, if possible */ 82 /* ID for this css, if possible */
80 struct css_id __rcu *id; 83 struct css_id __rcu *id;
@@ -666,15 +669,7 @@ struct cgroup_subsys {
666static inline 669static inline
667struct cgroup_subsys_state *css_parent(struct cgroup_subsys_state *css) 670struct cgroup_subsys_state *css_parent(struct cgroup_subsys_state *css)
668{ 671{
669 struct cgroup *parent_cgrp = css->cgroup->parent; 672 return css->parent;
670
671 if (!parent_cgrp)
672 return NULL;
673
674 if (css->ss)
675 return parent_cgrp->subsys[css->ss->subsys_id];
676 else
677 return &parent_cgrp->dummy_css;
678} 673}
679 674
680/** 675/**