aboutsummaryrefslogtreecommitdiffstats
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)
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 583f8f66a7e1..c049992f1ffa 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -1365,6 +1365,7 @@ static void init_cgroup_housekeeping(struct cgroup *cgrp)
1365 INIT_LIST_HEAD(&cgrp->release_list); 1365 INIT_LIST_HEAD(&cgrp->release_list);
1366 INIT_LIST_HEAD(&cgrp->pidlists); 1366 INIT_LIST_HEAD(&cgrp->pidlists);
1367 mutex_init(&cgrp->pidlist_mutex); 1367 mutex_init(&cgrp->pidlist_mutex);
1368 cgrp->dummy_css.cgroup = cgrp;
1368 INIT_LIST_HEAD(&cgrp->event_list); 1369 INIT_LIST_HEAD(&cgrp->event_list);
1369 spin_lock_init(&cgrp->event_list_lock); 1370 spin_lock_init(&cgrp->event_list_lock);
1370 simple_xattrs_init(&cgrp->xattrs); 1371 simple_xattrs_init(&cgrp->xattrs);
@@ -2285,7 +2286,7 @@ static struct cgroup_subsys_state *cgroup_file_css(struct cfent *cfe)
2285 2286
2286 if (cft->ss) 2287 if (cft->ss)
2287 return cgrp->subsys[cft->ss->subsys_id]; 2288 return cgrp->subsys[cft->ss->subsys_id];
2288 return NULL; 2289 return &cgrp->dummy_css;
2289} 2290}
2290 2291
2291/* A buffer size big enough for numbers or short strings */ 2292/* 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)
2467 * unpinned either on open failure or release. This ensures that 2468 * unpinned either on open failure or release. This ensures that
2468 * @css stays alive for all file operations. 2469 * @css stays alive for all file operations.
2469 */ 2470 */
2470 if (css && !css_tryget(css)) 2471 if (css->ss && !css_tryget(css))
2471 return -ENODEV; 2472 return -ENODEV;
2472 2473
2473 if (cft->read_map || cft->read_seq_string) { 2474 if (cft->read_map || cft->read_seq_string) {
@@ -2477,7 +2478,7 @@ static int cgroup_file_open(struct inode *inode, struct file *file)
2477 err = cft->open(inode, file); 2478 err = cft->open(inode, file);
2478 } 2479 }
2479 2480
2480 if (css && err) 2481 if (css->ss && err)
2481 css_put(css); 2482 css_put(css);
2482 return err; 2483 return err;
2483} 2484}
@@ -2491,7 +2492,7 @@ static int cgroup_file_release(struct inode *inode, struct file *file)
2491 2492
2492 if (cft->release) 2493 if (cft->release)
2493 ret = cft->release(inode, file); 2494 ret = cft->release(inode, file);
2494 if (css) 2495 if (css->ss)
2495 css_put(css); 2496 css_put(css);
2496 return ret; 2497 return ret;
2497} 2498}