aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/cgroup.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/cgroup.c')
-rw-r--r--kernel/cgroup.c45
1 files changed, 0 insertions, 45 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index ceeafe874b3f..dec62f5936ef 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -1073,28 +1073,24 @@ static int rebind_subsystems(struct cgroupfs_root *root,
1073 BUG_ON(cgrp->subsys[i]); 1073 BUG_ON(cgrp->subsys[i]);
1074 BUG_ON(!dummytop->subsys[i]); 1074 BUG_ON(!dummytop->subsys[i]);
1075 BUG_ON(dummytop->subsys[i]->cgroup != dummytop); 1075 BUG_ON(dummytop->subsys[i]->cgroup != dummytop);
1076 mutex_lock(&ss->hierarchy_mutex);
1077 cgrp->subsys[i] = dummytop->subsys[i]; 1076 cgrp->subsys[i] = dummytop->subsys[i];
1078 cgrp->subsys[i]->cgroup = cgrp; 1077 cgrp->subsys[i]->cgroup = cgrp;
1079 list_move(&ss->sibling, &root->subsys_list); 1078 list_move(&ss->sibling, &root->subsys_list);
1080 ss->root = root; 1079 ss->root = root;
1081 if (ss->bind) 1080 if (ss->bind)
1082 ss->bind(cgrp); 1081 ss->bind(cgrp);
1083 mutex_unlock(&ss->hierarchy_mutex);
1084 /* refcount was already taken, and we're keeping it */ 1082 /* refcount was already taken, and we're keeping it */
1085 } else if (bit & removed_bits) { 1083 } else if (bit & removed_bits) {
1086 /* We're removing this subsystem */ 1084 /* We're removing this subsystem */
1087 BUG_ON(ss == NULL); 1085 BUG_ON(ss == NULL);
1088 BUG_ON(cgrp->subsys[i] != dummytop->subsys[i]); 1086 BUG_ON(cgrp->subsys[i] != dummytop->subsys[i]);
1089 BUG_ON(cgrp->subsys[i]->cgroup != cgrp); 1087 BUG_ON(cgrp->subsys[i]->cgroup != cgrp);
1090 mutex_lock(&ss->hierarchy_mutex);
1091 if (ss->bind) 1088 if (ss->bind)
1092 ss->bind(dummytop); 1089 ss->bind(dummytop);
1093 dummytop->subsys[i]->cgroup = dummytop; 1090 dummytop->subsys[i]->cgroup = dummytop;
1094 cgrp->subsys[i] = NULL; 1091 cgrp->subsys[i] = NULL;
1095 subsys[i]->root = &rootnode; 1092 subsys[i]->root = &rootnode;
1096 list_move(&ss->sibling, &rootnode.subsys_list); 1093 list_move(&ss->sibling, &rootnode.subsys_list);
1097 mutex_unlock(&ss->hierarchy_mutex);
1098 /* subsystem is now free - drop reference on module */ 1094 /* subsystem is now free - drop reference on module */
1099 module_put(ss->module); 1095 module_put(ss->module);
1100 } else if (bit & final_bits) { 1096 } else if (bit & final_bits) {
@@ -3917,37 +3913,6 @@ static void init_cgroup_css(struct cgroup_subsys_state *css,
3917 set_bit(CSS_CLEAR_CSS_REFS, &css->flags); 3913 set_bit(CSS_CLEAR_CSS_REFS, &css->flags);
3918} 3914}
3919 3915
3920static void cgroup_lock_hierarchy(struct cgroupfs_root *root)
3921{
3922 /* We need to take each hierarchy_mutex in a consistent order */
3923 int i;
3924
3925 /*
3926 * No worry about a race with rebind_subsystems that might mess up the
3927 * locking order, since both parties are under cgroup_mutex.
3928 */
3929 for (i = 0; i < CGROUP_SUBSYS_COUNT; i++) {
3930 struct cgroup_subsys *ss = subsys[i];
3931 if (ss == NULL)
3932 continue;
3933 if (ss->root == root)
3934 mutex_lock(&ss->hierarchy_mutex);
3935 }
3936}
3937
3938static void cgroup_unlock_hierarchy(struct cgroupfs_root *root)
3939{
3940 int i;
3941
3942 for (i = 0; i < CGROUP_SUBSYS_COUNT; i++) {
3943 struct cgroup_subsys *ss = subsys[i];
3944 if (ss == NULL)
3945 continue;
3946 if (ss->root == root)
3947 mutex_unlock(&ss->hierarchy_mutex);
3948 }
3949}
3950
3951/* 3916/*
3952 * cgroup_create - create a cgroup 3917 * cgroup_create - create a cgroup
3953 * @parent: cgroup that will be parent of the new cgroup 3918 * @parent: cgroup that will be parent of the new cgroup
@@ -4008,9 +3973,7 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry,
4008 ss->post_clone(cgrp); 3973 ss->post_clone(cgrp);
4009 } 3974 }
4010 3975
4011 cgroup_lock_hierarchy(root);
4012 list_add(&cgrp->sibling, &cgrp->parent->children); 3976 list_add(&cgrp->sibling, &cgrp->parent->children);
4013 cgroup_unlock_hierarchy(root);
4014 root->number_of_cgroups++; 3977 root->number_of_cgroups++;
4015 3978
4016 err = cgroup_create_dir(cgrp, dentry, mode); 3979 err = cgroup_create_dir(cgrp, dentry, mode);
@@ -4037,9 +4000,7 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry,
4037 4000
4038 err_remove: 4001 err_remove:
4039 4002
4040 cgroup_lock_hierarchy(root);
4041 list_del(&cgrp->sibling); 4003 list_del(&cgrp->sibling);
4042 cgroup_unlock_hierarchy(root);
4043 root->number_of_cgroups--; 4004 root->number_of_cgroups--;
4044 4005
4045 err_destroy: 4006 err_destroy:
@@ -4247,10 +4208,8 @@ again:
4247 list_del_init(&cgrp->release_list); 4208 list_del_init(&cgrp->release_list);
4248 raw_spin_unlock(&release_list_lock); 4209 raw_spin_unlock(&release_list_lock);
4249 4210
4250 cgroup_lock_hierarchy(cgrp->root);
4251 /* delete this cgroup from parent->children */ 4211 /* delete this cgroup from parent->children */
4252 list_del_init(&cgrp->sibling); 4212 list_del_init(&cgrp->sibling);
4253 cgroup_unlock_hierarchy(cgrp->root);
4254 4213
4255 list_del_init(&cgrp->allcg_node); 4214 list_del_init(&cgrp->allcg_node);
4256 4215
@@ -4324,8 +4283,6 @@ static void __init cgroup_init_subsys(struct cgroup_subsys *ss)
4324 * need to invoke fork callbacks here. */ 4283 * need to invoke fork callbacks here. */
4325 BUG_ON(!list_empty(&init_task.tasks)); 4284 BUG_ON(!list_empty(&init_task.tasks));
4326 4285
4327 mutex_init(&ss->hierarchy_mutex);
4328 lockdep_set_class(&ss->hierarchy_mutex, &ss->subsys_key);
4329 ss->active = 1; 4286 ss->active = 1;
4330 4287
4331 /* this function shouldn't be used with modular subsystems, since they 4288 /* this function shouldn't be used with modular subsystems, since they
@@ -4452,8 +4409,6 @@ int __init_or_module cgroup_load_subsys(struct cgroup_subsys *ss)
4452 } 4409 }
4453 write_unlock(&css_set_lock); 4410 write_unlock(&css_set_lock);
4454 4411
4455 mutex_init(&ss->hierarchy_mutex);
4456 lockdep_set_class(&ss->hierarchy_mutex, &ss->subsys_key);
4457 ss->active = 1; 4412 ss->active = 1;
4458 4413
4459 /* success! */ 4414 /* success! */