aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/cgroup.c
diff options
context:
space:
mode:
authorAristeu Rozanski <aris@redhat.com>2012-08-23 16:53:31 -0400
committerTejun Heo <tj@kernel.org>2012-08-24 18:55:33 -0400
commita1a71b45a66fd3c3c453b55fbd180f8fccdd1daa (patch)
treebf1ffd6aa6cc5374a7787b5b197aaa440d8366b9 /kernel/cgroup.c
parent03b1cde6b22f625ae832b939bc7379ec1466aec5 (diff)
cgroup: rename subsys_bits to subsys_mask
In a previous discussion, Tejun Heo suggested to rename references to subsys_bits (added_bits, removed_bits, etc) by something more meaningful. Cc: Li Zefan <lizefan@huawei.com> Cc: Tejun Heo <tj@kernel.org> Cc: Hugh Dickins <hughd@google.com> Cc: Hillf Danton <dhillf@gmail.com> Cc: Lennart Poettering <lpoetter@redhat.com> Signed-off-by: Aristeu Rozanski <aris@redhat.com> Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'kernel/cgroup.c')
-rw-r--r--kernel/cgroup.c84
1 files changed, 42 insertions, 42 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 508b4a97ab19..ced292d720b9 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -111,13 +111,13 @@ struct cgroupfs_root {
111 * The bitmask of subsystems intended to be attached to this 111 * The bitmask of subsystems intended to be attached to this
112 * hierarchy 112 * hierarchy
113 */ 113 */
114 unsigned long subsys_bits; 114 unsigned long subsys_mask;
115 115
116 /* Unique id for this hierarchy. */ 116 /* Unique id for this hierarchy. */
117 int hierarchy_id; 117 int hierarchy_id;
118 118
119 /* The bitmask of subsystems currently attached to this hierarchy */ 119 /* The bitmask of subsystems currently attached to this hierarchy */
120 unsigned long actual_subsys_bits; 120 unsigned long actual_subsys_mask;
121 121
122 /* A list running through the attached subsystems */ 122 /* A list running through the attached subsystems */
123 struct list_head subsys_list; 123 struct list_head subsys_list;
@@ -557,7 +557,7 @@ static struct css_set *find_existing_css_set(
557 * won't change, so no need for locking. 557 * won't change, so no need for locking.
558 */ 558 */
559 for (i = 0; i < CGROUP_SUBSYS_COUNT; i++) { 559 for (i = 0; i < CGROUP_SUBSYS_COUNT; i++) {
560 if (root->subsys_bits & (1UL << i)) { 560 if (root->subsys_mask & (1UL << i)) {
561 /* Subsystem is in this hierarchy. So we want 561 /* Subsystem is in this hierarchy. So we want
562 * the subsystem state from the new 562 * the subsystem state from the new
563 * cgroup */ 563 * cgroup */
@@ -1002,7 +1002,7 @@ static void cgroup_d_remove_dir(struct dentry *dentry)
1002 struct dentry *parent; 1002 struct dentry *parent;
1003 struct cgroupfs_root *root = dentry->d_sb->s_fs_info; 1003 struct cgroupfs_root *root = dentry->d_sb->s_fs_info;
1004 1004
1005 cgroup_clear_directory(dentry, true, root->subsys_bits); 1005 cgroup_clear_directory(dentry, true, root->subsys_mask);
1006 1006
1007 parent = dentry->d_parent; 1007 parent = dentry->d_parent;
1008 spin_lock(&parent->d_lock); 1008 spin_lock(&parent->d_lock);
@@ -1046,22 +1046,22 @@ void cgroup_release_and_wakeup_rmdir(struct cgroup_subsys_state *css)
1046 * returns an error, no reference counts are touched. 1046 * returns an error, no reference counts are touched.
1047 */ 1047 */
1048static int rebind_subsystems(struct cgroupfs_root *root, 1048static int rebind_subsystems(struct cgroupfs_root *root,
1049 unsigned long final_bits) 1049 unsigned long final_subsys_mask)
1050{ 1050{
1051 unsigned long added_bits, removed_bits; 1051 unsigned long added_mask, removed_mask;
1052 struct cgroup *cgrp = &root->top_cgroup; 1052 struct cgroup *cgrp = &root->top_cgroup;
1053 int i; 1053 int i;
1054 1054
1055 BUG_ON(!mutex_is_locked(&cgroup_mutex)); 1055 BUG_ON(!mutex_is_locked(&cgroup_mutex));
1056 BUG_ON(!mutex_is_locked(&cgroup_root_mutex)); 1056 BUG_ON(!mutex_is_locked(&cgroup_root_mutex));
1057 1057
1058 removed_bits = root->actual_subsys_bits & ~final_bits; 1058 removed_mask = root->actual_subsys_mask & ~final_subsys_mask;
1059 added_bits = final_bits & ~root->actual_subsys_bits; 1059 added_mask = final_subsys_mask & ~root->actual_subsys_mask;
1060 /* Check that any added subsystems are currently free */ 1060 /* Check that any added subsystems are currently free */
1061 for (i = 0; i < CGROUP_SUBSYS_COUNT; i++) { 1061 for (i = 0; i < CGROUP_SUBSYS_COUNT; i++) {
1062 unsigned long bit = 1UL << i; 1062 unsigned long bit = 1UL << i;
1063 struct cgroup_subsys *ss = subsys[i]; 1063 struct cgroup_subsys *ss = subsys[i];
1064 if (!(bit & added_bits)) 1064 if (!(bit & added_mask))
1065 continue; 1065 continue;
1066 /* 1066 /*
1067 * Nobody should tell us to do a subsys that doesn't exist: 1067 * Nobody should tell us to do a subsys that doesn't exist:
@@ -1086,7 +1086,7 @@ static int rebind_subsystems(struct cgroupfs_root *root,
1086 for (i = 0; i < CGROUP_SUBSYS_COUNT; i++) { 1086 for (i = 0; i < CGROUP_SUBSYS_COUNT; i++) {
1087 struct cgroup_subsys *ss = subsys[i]; 1087 struct cgroup_subsys *ss = subsys[i];
1088 unsigned long bit = 1UL << i; 1088 unsigned long bit = 1UL << i;
1089 if (bit & added_bits) { 1089 if (bit & added_mask) {
1090 /* We're binding this subsystem to this hierarchy */ 1090 /* We're binding this subsystem to this hierarchy */
1091 BUG_ON(ss == NULL); 1091 BUG_ON(ss == NULL);
1092 BUG_ON(cgrp->subsys[i]); 1092 BUG_ON(cgrp->subsys[i]);
@@ -1099,7 +1099,7 @@ static int rebind_subsystems(struct cgroupfs_root *root,
1099 if (ss->bind) 1099 if (ss->bind)
1100 ss->bind(cgrp); 1100 ss->bind(cgrp);
1101 /* refcount was already taken, and we're keeping it */ 1101 /* refcount was already taken, and we're keeping it */
1102 } else if (bit & removed_bits) { 1102 } else if (bit & removed_mask) {
1103 /* We're removing this subsystem */ 1103 /* We're removing this subsystem */
1104 BUG_ON(ss == NULL); 1104 BUG_ON(ss == NULL);
1105 BUG_ON(cgrp->subsys[i] != dummytop->subsys[i]); 1105 BUG_ON(cgrp->subsys[i] != dummytop->subsys[i]);
@@ -1112,7 +1112,7 @@ static int rebind_subsystems(struct cgroupfs_root *root,
1112 list_move(&ss->sibling, &rootnode.subsys_list); 1112 list_move(&ss->sibling, &rootnode.subsys_list);
1113 /* subsystem is now free - drop reference on module */ 1113 /* subsystem is now free - drop reference on module */
1114 module_put(ss->module); 1114 module_put(ss->module);
1115 } else if (bit & final_bits) { 1115 } else if (bit & final_subsys_mask) {
1116 /* Subsystem state should already exist */ 1116 /* Subsystem state should already exist */
1117 BUG_ON(ss == NULL); 1117 BUG_ON(ss == NULL);
1118 BUG_ON(!cgrp->subsys[i]); 1118 BUG_ON(!cgrp->subsys[i]);
@@ -1129,7 +1129,7 @@ static int rebind_subsystems(struct cgroupfs_root *root,
1129 BUG_ON(cgrp->subsys[i]); 1129 BUG_ON(cgrp->subsys[i]);
1130 } 1130 }
1131 } 1131 }
1132 root->subsys_bits = root->actual_subsys_bits = final_bits; 1132 root->subsys_mask = root->actual_subsys_mask = final_subsys_mask;
1133 synchronize_rcu(); 1133 synchronize_rcu();
1134 1134
1135 return 0; 1135 return 0;
@@ -1158,7 +1158,7 @@ static int cgroup_show_options(struct seq_file *seq, struct dentry *dentry)
1158} 1158}
1159 1159
1160struct cgroup_sb_opts { 1160struct cgroup_sb_opts {
1161 unsigned long subsys_bits; 1161 unsigned long subsys_mask;
1162 unsigned long flags; 1162 unsigned long flags;
1163 char *release_agent; 1163 char *release_agent;
1164 bool clone_children; 1164 bool clone_children;
@@ -1267,7 +1267,7 @@ static int parse_cgroupfs_options(char *data, struct cgroup_sb_opts *opts)
1267 /* Mutually exclusive option 'all' + subsystem name */ 1267 /* Mutually exclusive option 'all' + subsystem name */
1268 if (all_ss) 1268 if (all_ss)
1269 return -EINVAL; 1269 return -EINVAL;
1270 set_bit(i, &opts->subsys_bits); 1270 set_bit(i, &opts->subsys_mask);
1271 one_ss = true; 1271 one_ss = true;
1272 1272
1273 break; 1273 break;
@@ -1288,7 +1288,7 @@ static int parse_cgroupfs_options(char *data, struct cgroup_sb_opts *opts)
1288 continue; 1288 continue;
1289 if (ss->disabled) 1289 if (ss->disabled)
1290 continue; 1290 continue;
1291 set_bit(i, &opts->subsys_bits); 1291 set_bit(i, &opts->subsys_mask);
1292 } 1292 }
1293 } 1293 }
1294 1294
@@ -1300,19 +1300,19 @@ static int parse_cgroupfs_options(char *data, struct cgroup_sb_opts *opts)
1300 * the cpuset subsystem. 1300 * the cpuset subsystem.
1301 */ 1301 */
1302 if (test_bit(ROOT_NOPREFIX, &opts->flags) && 1302 if (test_bit(ROOT_NOPREFIX, &opts->flags) &&
1303 (opts->subsys_bits & mask)) 1303 (opts->subsys_mask & mask))
1304 return -EINVAL; 1304 return -EINVAL;
1305 1305
1306 1306
1307 /* Can't specify "none" and some subsystems */ 1307 /* Can't specify "none" and some subsystems */
1308 if (opts->subsys_bits && opts->none) 1308 if (opts->subsys_mask && opts->none)
1309 return -EINVAL; 1309 return -EINVAL;
1310 1310
1311 /* 1311 /*
1312 * We either have to specify by name or by subsystems. (So all 1312 * We either have to specify by name or by subsystems. (So all
1313 * empty hierarchies must have a name). 1313 * empty hierarchies must have a name).
1314 */ 1314 */
1315 if (!opts->subsys_bits && !opts->name) 1315 if (!opts->subsys_mask && !opts->name)
1316 return -EINVAL; 1316 return -EINVAL;
1317 1317
1318 /* 1318 /*
@@ -1324,7 +1324,7 @@ static int parse_cgroupfs_options(char *data, struct cgroup_sb_opts *opts)
1324 for (i = CGROUP_BUILTIN_SUBSYS_COUNT; i < CGROUP_SUBSYS_COUNT; i++) { 1324 for (i = CGROUP_BUILTIN_SUBSYS_COUNT; i < CGROUP_SUBSYS_COUNT; i++) {
1325 unsigned long bit = 1UL << i; 1325 unsigned long bit = 1UL << i;
1326 1326
1327 if (!(bit & opts->subsys_bits)) 1327 if (!(bit & opts->subsys_mask))
1328 continue; 1328 continue;
1329 if (!try_module_get(subsys[i]->module)) { 1329 if (!try_module_get(subsys[i]->module)) {
1330 module_pin_failed = true; 1330 module_pin_failed = true;
@@ -1341,7 +1341,7 @@ static int parse_cgroupfs_options(char *data, struct cgroup_sb_opts *opts)
1341 /* drop refcounts only on the ones we took */ 1341 /* drop refcounts only on the ones we took */
1342 unsigned long bit = 1UL << i; 1342 unsigned long bit = 1UL << i;
1343 1343
1344 if (!(bit & opts->subsys_bits)) 1344 if (!(bit & opts->subsys_mask))
1345 continue; 1345 continue;
1346 module_put(subsys[i]->module); 1346 module_put(subsys[i]->module);
1347 } 1347 }
@@ -1351,13 +1351,13 @@ static int parse_cgroupfs_options(char *data, struct cgroup_sb_opts *opts)
1351 return 0; 1351 return 0;
1352} 1352}
1353 1353
1354static void drop_parsed_module_refcounts(unsigned long subsys_bits) 1354static void drop_parsed_module_refcounts(unsigned long subsys_mask)
1355{ 1355{
1356 int i; 1356 int i;
1357 for (i = CGROUP_BUILTIN_SUBSYS_COUNT; i < CGROUP_SUBSYS_COUNT; i++) { 1357 for (i = CGROUP_BUILTIN_SUBSYS_COUNT; i < CGROUP_SUBSYS_COUNT; i++) {
1358 unsigned long bit = 1UL << i; 1358 unsigned long bit = 1UL << i;
1359 1359
1360 if (!(bit & subsys_bits)) 1360 if (!(bit & subsys_mask))
1361 continue; 1361 continue;
1362 module_put(subsys[i]->module); 1362 module_put(subsys[i]->module);
1363 } 1363 }
@@ -1369,7 +1369,7 @@ static int cgroup_remount(struct super_block *sb, int *flags, char *data)
1369 struct cgroupfs_root *root = sb->s_fs_info; 1369 struct cgroupfs_root *root = sb->s_fs_info;
1370 struct cgroup *cgrp = &root->top_cgroup; 1370 struct cgroup *cgrp = &root->top_cgroup;
1371 struct cgroup_sb_opts opts; 1371 struct cgroup_sb_opts opts;
1372 unsigned long added_bits, removed_bits; 1372 unsigned long added_mask, removed_mask;
1373 1373
1374 mutex_lock(&cgrp->dentry->d_inode->i_mutex); 1374 mutex_lock(&cgrp->dentry->d_inode->i_mutex);
1375 mutex_lock(&cgroup_mutex); 1375 mutex_lock(&cgroup_mutex);
@@ -1381,31 +1381,31 @@ static int cgroup_remount(struct super_block *sb, int *flags, char *data)
1381 goto out_unlock; 1381 goto out_unlock;
1382 1382
1383 /* See feature-removal-schedule.txt */ 1383 /* See feature-removal-schedule.txt */
1384 if (opts.subsys_bits != root->actual_subsys_bits || opts.release_agent) 1384 if (opts.subsys_mask != root->actual_subsys_mask || opts.release_agent)
1385 pr_warning("cgroup: option changes via remount are deprecated (pid=%d comm=%s)\n", 1385 pr_warning("cgroup: option changes via remount are deprecated (pid=%d comm=%s)\n",
1386 task_tgid_nr(current), current->comm); 1386 task_tgid_nr(current), current->comm);
1387 1387
1388 added_bits = opts.subsys_bits & ~root->subsys_bits; 1388 added_mask = opts.subsys_mask & ~root->subsys_mask;
1389 removed_bits = root->subsys_bits & ~opts.subsys_bits; 1389 removed_mask = root->subsys_mask & ~opts.subsys_mask;
1390 1390
1391 /* Don't allow flags or name to change at remount */ 1391 /* Don't allow flags or name to change at remount */
1392 if (opts.flags != root->flags || 1392 if (opts.flags != root->flags ||
1393 (opts.name && strcmp(opts.name, root->name))) { 1393 (opts.name && strcmp(opts.name, root->name))) {
1394 ret = -EINVAL; 1394 ret = -EINVAL;
1395 drop_parsed_module_refcounts(opts.subsys_bits); 1395 drop_parsed_module_refcounts(opts.subsys_mask);
1396 goto out_unlock; 1396 goto out_unlock;
1397 } 1397 }
1398 1398
1399 ret = rebind_subsystems(root, opts.subsys_bits); 1399 ret = rebind_subsystems(root, opts.subsys_mask);
1400 if (ret) { 1400 if (ret) {
1401 drop_parsed_module_refcounts(opts.subsys_bits); 1401 drop_parsed_module_refcounts(opts.subsys_mask);
1402 goto out_unlock; 1402 goto out_unlock;
1403 } 1403 }
1404 1404
1405 /* clear out any existing files and repopulate subsystem files */ 1405 /* clear out any existing files and repopulate subsystem files */
1406 cgroup_clear_directory(cgrp->dentry, false, removed_bits); 1406 cgroup_clear_directory(cgrp->dentry, false, removed_mask);
1407 /* re-populate subsystem files */ 1407 /* re-populate subsystem files */
1408 cgroup_populate_dir(cgrp, false, added_bits); 1408 cgroup_populate_dir(cgrp, false, added_mask);
1409 1409
1410 if (opts.release_agent) 1410 if (opts.release_agent)
1411 strcpy(root->release_agent_path, opts.release_agent); 1411 strcpy(root->release_agent_path, opts.release_agent);
@@ -1491,8 +1491,8 @@ static int cgroup_test_super(struct super_block *sb, void *data)
1491 * If we asked for subsystems (or explicitly for no 1491 * If we asked for subsystems (or explicitly for no
1492 * subsystems) then they must match 1492 * subsystems) then they must match
1493 */ 1493 */
1494 if ((opts->subsys_bits || opts->none) 1494 if ((opts->subsys_mask || opts->none)
1495 && (opts->subsys_bits != root->subsys_bits)) 1495 && (opts->subsys_mask != root->subsys_mask))
1496 return 0; 1496 return 0;
1497 1497
1498 return 1; 1498 return 1;
@@ -1502,7 +1502,7 @@ static struct cgroupfs_root *cgroup_root_from_opts(struct cgroup_sb_opts *opts)
1502{ 1502{
1503 struct cgroupfs_root *root; 1503 struct cgroupfs_root *root;
1504 1504
1505 if (!opts->subsys_bits && !opts->none) 1505 if (!opts->subsys_mask && !opts->none)
1506 return NULL; 1506 return NULL;
1507 1507
1508 root = kzalloc(sizeof(*root), GFP_KERNEL); 1508 root = kzalloc(sizeof(*root), GFP_KERNEL);
@@ -1515,7 +1515,7 @@ static struct cgroupfs_root *cgroup_root_from_opts(struct cgroup_sb_opts *opts)
1515 } 1515 }
1516 init_cgroup_root(root); 1516 init_cgroup_root(root);
1517 1517
1518 root->subsys_bits = opts->subsys_bits; 1518 root->subsys_mask = opts->subsys_mask;
1519 root->flags = opts->flags; 1519 root->flags = opts->flags;
1520 if (opts->release_agent) 1520 if (opts->release_agent)
1521 strcpy(root->release_agent_path, opts->release_agent); 1521 strcpy(root->release_agent_path, opts->release_agent);
@@ -1547,7 +1547,7 @@ static int cgroup_set_super(struct super_block *sb, void *data)
1547 if (!opts->new_root) 1547 if (!opts->new_root)
1548 return -EINVAL; 1548 return -EINVAL;
1549 1549
1550 BUG_ON(!opts->subsys_bits && !opts->none); 1550 BUG_ON(!opts->subsys_mask && !opts->none);
1551 1551
1552 ret = set_anon_super(sb, NULL); 1552 ret = set_anon_super(sb, NULL);
1553 if (ret) 1553 if (ret)
@@ -1665,7 +1665,7 @@ static struct dentry *cgroup_mount(struct file_system_type *fs_type,
1665 if (ret) 1665 if (ret)
1666 goto unlock_drop; 1666 goto unlock_drop;
1667 1667
1668 ret = rebind_subsystems(root, root->subsys_bits); 1668 ret = rebind_subsystems(root, root->subsys_mask);
1669 if (ret == -EBUSY) { 1669 if (ret == -EBUSY) {
1670 free_cg_links(&tmp_cg_links); 1670 free_cg_links(&tmp_cg_links);
1671 goto unlock_drop; 1671 goto unlock_drop;
@@ -1705,7 +1705,7 @@ static struct dentry *cgroup_mount(struct file_system_type *fs_type,
1705 BUG_ON(root->number_of_cgroups != 1); 1705 BUG_ON(root->number_of_cgroups != 1);
1706 1706
1707 cred = override_creds(&init_cred); 1707 cred = override_creds(&init_cred);
1708 cgroup_populate_dir(root_cgrp, true, root->subsys_bits); 1708 cgroup_populate_dir(root_cgrp, true, root->subsys_mask);
1709 revert_creds(cred); 1709 revert_creds(cred);
1710 mutex_unlock(&cgroup_root_mutex); 1710 mutex_unlock(&cgroup_root_mutex);
1711 mutex_unlock(&cgroup_mutex); 1711 mutex_unlock(&cgroup_mutex);
@@ -1717,7 +1717,7 @@ static struct dentry *cgroup_mount(struct file_system_type *fs_type,
1717 */ 1717 */
1718 cgroup_drop_root(opts.new_root); 1718 cgroup_drop_root(opts.new_root);
1719 /* no subsys rebinding, so refcounts don't change */ 1719 /* no subsys rebinding, so refcounts don't change */
1720 drop_parsed_module_refcounts(opts.subsys_bits); 1720 drop_parsed_module_refcounts(opts.subsys_mask);
1721 } 1721 }
1722 1722
1723 kfree(opts.release_agent); 1723 kfree(opts.release_agent);
@@ -1731,7 +1731,7 @@ static struct dentry *cgroup_mount(struct file_system_type *fs_type,
1731 drop_new_super: 1731 drop_new_super:
1732 deactivate_locked_super(sb); 1732 deactivate_locked_super(sb);
1733 drop_modules: 1733 drop_modules:
1734 drop_parsed_module_refcounts(opts.subsys_bits); 1734 drop_parsed_module_refcounts(opts.subsys_mask);
1735 out_err: 1735 out_err:
1736 kfree(opts.release_agent); 1736 kfree(opts.release_agent);
1737 kfree(opts.name); 1737 kfree(opts.name);
@@ -4109,7 +4109,7 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry,
4109 4109
4110 list_add_tail(&cgrp->allcg_node, &root->allcg_list); 4110 list_add_tail(&cgrp->allcg_node, &root->allcg_list);
4111 4111
4112 err = cgroup_populate_dir(cgrp, true, root->subsys_bits); 4112 err = cgroup_populate_dir(cgrp, true, root->subsys_mask);
4113 /* If err < 0, we have a half-filled directory - oh well ;) */ 4113 /* If err < 0, we have a half-filled directory - oh well ;) */
4114 4114
4115 mutex_unlock(&cgroup_mutex); 4115 mutex_unlock(&cgroup_mutex);