diff options
Diffstat (limited to 'kernel/cgroup.c')
-rw-r--r-- | kernel/cgroup.c | 54 |
1 files changed, 41 insertions, 13 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index b24d7027b83..95362d15128 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
@@ -4230,20 +4230,8 @@ void cgroup_post_fork(struct task_struct *child) | |||
4230 | */ | 4230 | */ |
4231 | void cgroup_exit(struct task_struct *tsk, int run_callbacks) | 4231 | void cgroup_exit(struct task_struct *tsk, int run_callbacks) |
4232 | { | 4232 | { |
4233 | int i; | ||
4234 | struct css_set *cg; | 4233 | struct css_set *cg; |
4235 | 4234 | int i; | |
4236 | if (run_callbacks && need_forkexit_callback) { | ||
4237 | /* | ||
4238 | * modular subsystems can't use callbacks, so no need to lock | ||
4239 | * the subsys array | ||
4240 | */ | ||
4241 | for (i = 0; i < CGROUP_BUILTIN_SUBSYS_COUNT; i++) { | ||
4242 | struct cgroup_subsys *ss = subsys[i]; | ||
4243 | if (ss->exit) | ||
4244 | ss->exit(ss, tsk); | ||
4245 | } | ||
4246 | } | ||
4247 | 4235 | ||
4248 | /* | 4236 | /* |
4249 | * Unlink from the css_set task list if necessary. | 4237 | * Unlink from the css_set task list if necessary. |
@@ -4261,7 +4249,24 @@ void cgroup_exit(struct task_struct *tsk, int run_callbacks) | |||
4261 | task_lock(tsk); | 4249 | task_lock(tsk); |
4262 | cg = tsk->cgroups; | 4250 | cg = tsk->cgroups; |
4263 | tsk->cgroups = &init_css_set; | 4251 | tsk->cgroups = &init_css_set; |
4252 | |||
4253 | if (run_callbacks && need_forkexit_callback) { | ||
4254 | /* | ||
4255 | * modular subsystems can't use callbacks, so no need to lock | ||
4256 | * the subsys array | ||
4257 | */ | ||
4258 | for (i = 0; i < CGROUP_BUILTIN_SUBSYS_COUNT; i++) { | ||
4259 | struct cgroup_subsys *ss = subsys[i]; | ||
4260 | if (ss->exit) { | ||
4261 | struct cgroup *old_cgrp = | ||
4262 | rcu_dereference_raw(cg->subsys[i])->cgroup; | ||
4263 | struct cgroup *cgrp = task_cgroup(tsk, i); | ||
4264 | ss->exit(ss, cgrp, old_cgrp, tsk); | ||
4265 | } | ||
4266 | } | ||
4267 | } | ||
4264 | task_unlock(tsk); | 4268 | task_unlock(tsk); |
4269 | |||
4265 | if (cg) | 4270 | if (cg) |
4266 | put_css_set_taskexit(cg); | 4271 | put_css_set_taskexit(cg); |
4267 | } | 4272 | } |
@@ -4813,6 +4818,29 @@ css_get_next(struct cgroup_subsys *ss, int id, | |||
4813 | return ret; | 4818 | return ret; |
4814 | } | 4819 | } |
4815 | 4820 | ||
4821 | /* | ||
4822 | * get corresponding css from file open on cgroupfs directory | ||
4823 | */ | ||
4824 | struct cgroup_subsys_state *cgroup_css_from_dir(struct file *f, int id) | ||
4825 | { | ||
4826 | struct cgroup *cgrp; | ||
4827 | struct inode *inode; | ||
4828 | struct cgroup_subsys_state *css; | ||
4829 | |||
4830 | inode = f->f_dentry->d_inode; | ||
4831 | /* check in cgroup filesystem dir */ | ||
4832 | if (inode->i_op != &cgroup_dir_inode_operations) | ||
4833 | return ERR_PTR(-EBADF); | ||
4834 | |||
4835 | if (id < 0 || id >= CGROUP_SUBSYS_COUNT) | ||
4836 | return ERR_PTR(-EINVAL); | ||
4837 | |||
4838 | /* get cgroup */ | ||
4839 | cgrp = __d_cgrp(f->f_dentry); | ||
4840 | css = cgrp->subsys[id]; | ||
4841 | return css ? css : ERR_PTR(-ENOENT); | ||
4842 | } | ||
4843 | |||
4816 | #ifdef CONFIG_CGROUP_DEBUG | 4844 | #ifdef CONFIG_CGROUP_DEBUG |
4817 | static struct cgroup_subsys_state *debug_create(struct cgroup_subsys *ss, | 4845 | static struct cgroup_subsys_state *debug_create(struct cgroup_subsys *ss, |
4818 | struct cgroup *cont) | 4846 | struct cgroup *cont) |