aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2013-12-06 15:11:57 -0500
committerTejun Heo <tj@kernel.org>2013-12-06 15:11:57 -0500
commitb85d20404cef6493f9d2edbafe83f9c72aece9a8 (patch)
tree865a0a474f729925586cf17dfe735e151379afce
parent1c6727af4b495a9ec74c46d1fc08e508e675899d (diff)
cgroup: remove for_each_root_subsys()
After the previous patch which introduced for_each_css(), for_each_root_subsys() only has two users left. This patch replaces it with for_each_subsys() + explicit subsys_mask testing and remove for_each_root_subsys() along with cgroupfs_root->subsys_list handling. This patch doesn't introduce any behavior changes. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Li Zefan <lizefan@huawei.com>
-rw-r--r--include/linux/cgroup.h9
-rw-r--r--kernel/cgroup.c37
2 files changed, 16 insertions, 30 deletions
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index 8b9a594f0c92..cfaf416492dd 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -319,9 +319,6 @@ struct cgroupfs_root {
319 /* Unique id for this hierarchy. */ 319 /* Unique id for this hierarchy. */
320 int hierarchy_id; 320 int hierarchy_id;
321 321
322 /* A list running through the attached subsystems */
323 struct list_head subsys_list;
324
325 /* The root cgroup for this hierarchy */ 322 /* The root cgroup for this hierarchy */
326 struct cgroup top_cgroup; 323 struct cgroup top_cgroup;
327 324
@@ -617,12 +614,8 @@ struct cgroup_subsys {
617#define MAX_CGROUP_TYPE_NAMELEN 32 614#define MAX_CGROUP_TYPE_NAMELEN 32
618 const char *name; 615 const char *name;
619 616
620 /* 617 /* link to parent, protected by cgroup_lock() */
621 * Link to parent, and list entry in parent's children.
622 * Protected by cgroup_lock()
623 */
624 struct cgroupfs_root *root; 618 struct cgroupfs_root *root;
625 struct list_head sibling;
626 619
627 /* list of cftype_sets */ 620 /* list of cftype_sets */
628 struct list_head cftsets; 621 struct list_head cftsets;
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 329fde82ef7c..fb1193bec4af 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -283,10 +283,6 @@ static int notify_on_release(const struct cgroup *cgrp)
283 for ((i) = 0; (i) < CGROUP_BUILTIN_SUBSYS_COUNT && \ 283 for ((i) = 0; (i) < CGROUP_BUILTIN_SUBSYS_COUNT && \
284 (((ss) = cgroup_subsys[i]) || true); (i)++) 284 (((ss) = cgroup_subsys[i]) || true); (i)++)
285 285
286/* iterate each subsystem attached to a hierarchy */
287#define for_each_root_subsys(root, ss) \
288 list_for_each_entry((ss), &(root)->subsys_list, sibling)
289
290/* iterate across the active hierarchies */ 286/* iterate across the active hierarchies */
291#define for_each_active_root(root) \ 287#define for_each_active_root(root) \
292 list_for_each_entry((root), &cgroup_roots, root_list) 288 list_for_each_entry((root), &cgroup_roots, root_list)
@@ -1033,7 +1029,6 @@ static int rebind_subsystems(struct cgroupfs_root *root,
1033 cgroup_css(cgroup_dummy_top, ss)); 1029 cgroup_css(cgroup_dummy_top, ss));
1034 cgroup_css(cgrp, ss)->cgroup = cgrp; 1030 cgroup_css(cgrp, ss)->cgroup = cgrp;
1035 1031
1036 list_move(&ss->sibling, &root->subsys_list);
1037 ss->root = root; 1032 ss->root = root;
1038 if (ss->bind) 1033 if (ss->bind)
1039 ss->bind(cgroup_css(cgrp, ss)); 1034 ss->bind(cgroup_css(cgrp, ss));
@@ -1052,7 +1047,6 @@ static int rebind_subsystems(struct cgroupfs_root *root,
1052 RCU_INIT_POINTER(cgrp->subsys[i], NULL); 1047 RCU_INIT_POINTER(cgrp->subsys[i], NULL);
1053 1048
1054 cgroup_subsys[i]->root = &cgroup_dummy_root; 1049 cgroup_subsys[i]->root = &cgroup_dummy_root;
1055 list_move(&ss->sibling, &cgroup_dummy_root.subsys_list);
1056 1050
1057 /* subsystem is now free - drop reference on module */ 1051 /* subsystem is now free - drop reference on module */
1058 module_put(ss->module); 1052 module_put(ss->module);
@@ -1079,10 +1073,12 @@ static int cgroup_show_options(struct seq_file *seq, struct dentry *dentry)
1079{ 1073{
1080 struct cgroupfs_root *root = dentry->d_sb->s_fs_info; 1074 struct cgroupfs_root *root = dentry->d_sb->s_fs_info;
1081 struct cgroup_subsys *ss; 1075 struct cgroup_subsys *ss;
1076 int ssid;
1082 1077
1083 mutex_lock(&cgroup_root_mutex); 1078 mutex_lock(&cgroup_root_mutex);
1084 for_each_root_subsys(root, ss) 1079 for_each_subsys(ss, ssid)
1085 seq_printf(seq, ",%s", ss->name); 1080 if (root->subsys_mask & (1 << ssid))
1081 seq_printf(seq, ",%s", ss->name);
1086 if (root->flags & CGRP_ROOT_SANE_BEHAVIOR) 1082 if (root->flags & CGRP_ROOT_SANE_BEHAVIOR)
1087 seq_puts(seq, ",sane_behavior"); 1083 seq_puts(seq, ",sane_behavior");
1088 if (root->flags & CGRP_ROOT_NOPREFIX) 1084 if (root->flags & CGRP_ROOT_NOPREFIX)
@@ -1352,7 +1348,6 @@ static void init_cgroup_root(struct cgroupfs_root *root)
1352{ 1348{
1353 struct cgroup *cgrp = &root->top_cgroup; 1349 struct cgroup *cgrp = &root->top_cgroup;
1354 1350
1355 INIT_LIST_HEAD(&root->subsys_list);
1356 INIT_LIST_HEAD(&root->root_list); 1351 INIT_LIST_HEAD(&root->root_list);
1357 root->number_of_cgroups = 1; 1352 root->number_of_cgroups = 1;
1358 cgrp->root = root; 1353 cgrp->root = root;
@@ -4151,7 +4146,7 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry,
4151 struct cgroup *cgrp; 4146 struct cgroup *cgrp;
4152 struct cgroup_name *name; 4147 struct cgroup_name *name;
4153 struct cgroupfs_root *root = parent->root; 4148 struct cgroupfs_root *root = parent->root;
4154 int err = 0; 4149 int ssid, err = 0;
4155 struct cgroup_subsys *ss; 4150 struct cgroup_subsys *ss;
4156 struct super_block *sb = root->sb; 4151 struct super_block *sb = root->sb;
4157 4152
@@ -4237,10 +4232,12 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry,
4237 goto err_destroy; 4232 goto err_destroy;
4238 4233
4239 /* let's create and online css's */ 4234 /* let's create and online css's */
4240 for_each_root_subsys(root, ss) { 4235 for_each_subsys(ss, ssid) {
4241 err = create_css(cgrp, ss); 4236 if (root->subsys_mask & (1 << ssid)) {
4242 if (err) 4237 err = create_css(cgrp, ss);
4243 goto err_destroy; 4238 if (err)
4239 goto err_destroy;
4240 }
4244 } 4241 }
4245 4242
4246 mutex_unlock(&cgroup_mutex); 4243 mutex_unlock(&cgroup_mutex);
@@ -4536,7 +4533,6 @@ static void __init cgroup_init_subsys(struct cgroup_subsys *ss)
4536 cgroup_init_cftsets(ss); 4533 cgroup_init_cftsets(ss);
4537 4534
4538 /* Create the top cgroup state for this subsystem */ 4535 /* Create the top cgroup state for this subsystem */
4539 list_add(&ss->sibling, &cgroup_dummy_root.subsys_list);
4540 ss->root = &cgroup_dummy_root; 4536 ss->root = &cgroup_dummy_root;
4541 css = ss->css_alloc(cgroup_css(cgroup_dummy_top, ss)); 4537 css = ss->css_alloc(cgroup_css(cgroup_dummy_top, ss));
4542 /* We don't handle early failures gracefully */ 4538 /* We don't handle early failures gracefully */
@@ -4626,7 +4622,6 @@ int __init_or_module cgroup_load_subsys(struct cgroup_subsys *ss)
4626 return PTR_ERR(css); 4622 return PTR_ERR(css);
4627 } 4623 }
4628 4624
4629 list_add(&ss->sibling, &cgroup_dummy_root.subsys_list);
4630 ss->root = &cgroup_dummy_root; 4625 ss->root = &cgroup_dummy_root;
4631 4626
4632 /* our new subsystem will be attached to the dummy hierarchy. */ 4627 /* our new subsystem will be attached to the dummy hierarchy. */
@@ -4702,9 +4697,6 @@ void cgroup_unload_subsys(struct cgroup_subsys *ss)
4702 /* deassign the subsys_id */ 4697 /* deassign the subsys_id */
4703 cgroup_subsys[ss->subsys_id] = NULL; 4698 cgroup_subsys[ss->subsys_id] = NULL;
4704 4699
4705 /* remove subsystem from the dummy root's list of subsystems */
4706 list_del_init(&ss->sibling);
4707
4708 /* 4700 /*
4709 * disentangle the css from all css_sets attached to the dummy 4701 * disentangle the css from all css_sets attached to the dummy
4710 * top. as in loading, we need to pay our respects to the hashtable 4702 * top. as in loading, we need to pay our respects to the hashtable
@@ -4901,11 +4893,12 @@ int proc_cgroup_show(struct seq_file *m, void *v)
4901 for_each_active_root(root) { 4893 for_each_active_root(root) {
4902 struct cgroup_subsys *ss; 4894 struct cgroup_subsys *ss;
4903 struct cgroup *cgrp; 4895 struct cgroup *cgrp;
4904 int count = 0; 4896 int ssid, count = 0;
4905 4897
4906 seq_printf(m, "%d:", root->hierarchy_id); 4898 seq_printf(m, "%d:", root->hierarchy_id);
4907 for_each_root_subsys(root, ss) 4899 for_each_subsys(ss, ssid)
4908 seq_printf(m, "%s%s", count++ ? "," : "", ss->name); 4900 if (root->subsys_mask & (1 << ssid))
4901 seq_printf(m, "%s%s", count++ ? "," : "", ss->name);
4909 if (strlen(root->name)) 4902 if (strlen(root->name))
4910 seq_printf(m, "%sname=%s", count ? "," : "", 4903 seq_printf(m, "%sname=%s", count ? "," : "",
4911 root->name); 4904 root->name);