summaryrefslogtreecommitdiffstats
path: root/kernel/cgroup.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2013-08-08 20:11:24 -0400
committerTejun Heo <tj@kernel.org>2013-08-08 20:11:24 -0400
commit67f4c36f83455b253445b2cb28ac9a2c4f85d99a (patch)
tree3c7aecc6fc830799cf36716ea64583cc10cb9d40 /kernel/cgroup.c
parentf7d58818ba4249f04a83b73aaac135640050bb4f (diff)
downloadop-kernel-dev-67f4c36f83455b253445b2cb28ac9a2c4f85d99a.zip
op-kernel-dev-67f4c36f83455b253445b2cb28ac9a2c4f85d99a.tar.gz
cgroup: add cgroup->dummy_css
cgroup subsystem API is being converted to use css (cgroup_subsys_state) as the main handle, which makes things a bit awkward for subsystem agnostic core features - the "cgroup.*" interface files and various iterations - a bit awkward as they don't have a css to use. This patch adds cgroup->dummy_css which has NULL ->ss and whose only role is pointing back to the cgroup. This will be used to support subsystem agnostic features on the coming css based API. css_parent() is updated to handle dummy_css's. Note that css will soon grow its own ->parent field and css_parent() will be made trivial. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Li Zefan <lizefan@huawei.com>
Diffstat (limited to 'kernel/cgroup.c')
-rw-r--r--kernel/cgroup.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 583f8f6..c049992 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -1365,6 +1365,7 @@ static void init_cgroup_housekeeping(struct cgroup *cgrp)
INIT_LIST_HEAD(&cgrp->release_list);
INIT_LIST_HEAD(&cgrp->pidlists);
mutex_init(&cgrp->pidlist_mutex);
+ cgrp->dummy_css.cgroup = cgrp;
INIT_LIST_HEAD(&cgrp->event_list);
spin_lock_init(&cgrp->event_list_lock);
simple_xattrs_init(&cgrp->xattrs);
@@ -2285,7 +2286,7 @@ static struct cgroup_subsys_state *cgroup_file_css(struct cfent *cfe)
if (cft->ss)
return cgrp->subsys[cft->ss->subsys_id];
- return NULL;
+ return &cgrp->dummy_css;
}
/* A buffer size big enough for numbers or short strings */
@@ -2467,7 +2468,7 @@ static int cgroup_file_open(struct inode *inode, struct file *file)
* unpinned either on open failure or release. This ensures that
* @css stays alive for all file operations.
*/
- if (css && !css_tryget(css))
+ if (css->ss && !css_tryget(css))
return -ENODEV;
if (cft->read_map || cft->read_seq_string) {
@@ -2477,7 +2478,7 @@ static int cgroup_file_open(struct inode *inode, struct file *file)
err = cft->open(inode, file);
}
- if (css && err)
+ if (css->ss && err)
css_put(css);
return err;
}
@@ -2491,7 +2492,7 @@ static int cgroup_file_release(struct inode *inode, struct file *file)
if (cft->release)
ret = cft->release(inode, file);
- if (css)
+ if (css->ss)
css_put(css);
return ret;
}
OpenPOWER on IntegriCloud