/* bits in struct cgroup_subsys_state flags field */
enum {
- CSS_ROOT = (1 << 0), /* this CSS is the root of the subsystem */
CSS_ONLINE = (1 << 1), /* between ->css_online() and ->css_offline() */
};
*/
static inline void css_get(struct cgroup_subsys_state *css)
{
- /* We don't need to reference count the root state */
- if (!(css->flags & CSS_ROOT))
- percpu_ref_get(&css->refcnt);
+ percpu_ref_get(&css->refcnt);
}
/**
*/
static inline bool css_tryget_online(struct cgroup_subsys_state *css)
{
- if (css->flags & CSS_ROOT)
- return true;
return percpu_ref_tryget_live(&css->refcnt);
}
*/
static inline void css_put(struct cgroup_subsys_state *css)
{
- if (!(css->flags & CSS_ROOT))
- percpu_ref_put(&css->refcnt);
+ percpu_ref_put(&css->refcnt);
}
/* bits in struct cgroup flags field */
if (cgrp->parent) {
css->parent = cgroup_css(cgrp->parent, ss);
css_get(css->parent);
- } else {
- css->flags |= CSS_ROOT;
}
BUG_ON(cgroup_css(cgrp, ss));
BUG_ON(IS_ERR(css));
init_and_link_css(css, ss, &cgrp_dfl_root.cgrp);
if (early) {
- /* idr_alloc() can't be called safely during early init */
+ /* allocation can't be done safely during early init */
css->id = 1;
} else {
+ BUG_ON(percpu_ref_init(&css->refcnt, css_release));
css->id = cgroup_idr_alloc(&ss->css_idr, css, 1, 2, GFP_KERNEL);
BUG_ON(css->id < 0);
}
struct cgroup_subsys_state *css =
init_css_set.subsys[ss->id];
+ BUG_ON(percpu_ref_init(&css->refcnt, css_release));
css->id = cgroup_idr_alloc(&ss->css_idr, css, 1, 2,
GFP_KERNEL);
BUG_ON(css->id < 0);