diff options
Diffstat (limited to 'kernel/cgroup.c')
-rw-r--r-- | kernel/cgroup.c | 47 |
1 files changed, 22 insertions, 25 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index c8d3175c429c..605cb13a1574 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
@@ -259,16 +259,13 @@ static int notify_on_release(const struct cgroup *cgrp) | |||
259 | return test_bit(CGRP_NOTIFY_ON_RELEASE, &cgrp->flags); | 259 | return test_bit(CGRP_NOTIFY_ON_RELEASE, &cgrp->flags); |
260 | } | 260 | } |
261 | 261 | ||
262 | /* | 262 | /* iterate each subsystem attached to a hierarchy */ |
263 | * for_each_subsys() allows you to iterate on each subsystem attached to | 263 | #define for_each_root_subsys(root, ss) \ |
264 | * an active hierarchy | 264 | list_for_each_entry((ss), &(root)->subsys_list, sibling) |
265 | */ | ||
266 | #define for_each_subsys(_root, _ss) \ | ||
267 | list_for_each_entry(_ss, &_root->subsys_list, sibling) | ||
268 | 265 | ||
269 | /* for_each_active_root() allows you to iterate across the active hierarchies */ | 266 | /* iterate across the active hierarchies */ |
270 | #define for_each_active_root(_root) \ | 267 | #define for_each_active_root(root) \ |
271 | list_for_each_entry(_root, &cgroup_roots, root_list) | 268 | list_for_each_entry((root), &cgroup_roots, root_list) |
272 | 269 | ||
273 | static inline struct cgroup *__d_cgrp(struct dentry *dentry) | 270 | static inline struct cgroup *__d_cgrp(struct dentry *dentry) |
274 | { | 271 | { |
@@ -828,7 +825,7 @@ static void cgroup_free_fn(struct work_struct *work) | |||
828 | /* | 825 | /* |
829 | * Release the subsystem state objects. | 826 | * Release the subsystem state objects. |
830 | */ | 827 | */ |
831 | for_each_subsys(cgrp->root, ss) | 828 | for_each_root_subsys(cgrp->root, ss) |
832 | ss->css_free(cgrp); | 829 | ss->css_free(cgrp); |
833 | 830 | ||
834 | cgrp->root->number_of_cgroups--; | 831 | cgrp->root->number_of_cgroups--; |
@@ -944,7 +941,7 @@ static void cgroup_clear_directory(struct dentry *dir, bool base_files, | |||
944 | struct cgroup *cgrp = __d_cgrp(dir); | 941 | struct cgroup *cgrp = __d_cgrp(dir); |
945 | struct cgroup_subsys *ss; | 942 | struct cgroup_subsys *ss; |
946 | 943 | ||
947 | for_each_subsys(cgrp->root, ss) { | 944 | for_each_root_subsys(cgrp->root, ss) { |
948 | struct cftype_set *set; | 945 | struct cftype_set *set; |
949 | if (!test_bit(ss->subsys_id, &subsys_mask)) | 946 | if (!test_bit(ss->subsys_id, &subsys_mask)) |
950 | continue; | 947 | continue; |
@@ -1078,7 +1075,7 @@ static int cgroup_show_options(struct seq_file *seq, struct dentry *dentry) | |||
1078 | struct cgroup_subsys *ss; | 1075 | struct cgroup_subsys *ss; |
1079 | 1076 | ||
1080 | mutex_lock(&cgroup_root_mutex); | 1077 | mutex_lock(&cgroup_root_mutex); |
1081 | for_each_subsys(root, ss) | 1078 | for_each_root_subsys(root, ss) |
1082 | seq_printf(seq, ",%s", ss->name); | 1079 | seq_printf(seq, ",%s", ss->name); |
1083 | if (root->flags & CGRP_ROOT_SANE_BEHAVIOR) | 1080 | if (root->flags & CGRP_ROOT_SANE_BEHAVIOR) |
1084 | seq_puts(seq, ",sane_behavior"); | 1081 | seq_puts(seq, ",sane_behavior"); |
@@ -2054,7 +2051,7 @@ static int cgroup_attach_task(struct cgroup *cgrp, struct task_struct *tsk, | |||
2054 | /* | 2051 | /* |
2055 | * step 1: check that we can legitimately attach to the cgroup. | 2052 | * step 1: check that we can legitimately attach to the cgroup. |
2056 | */ | 2053 | */ |
2057 | for_each_subsys(root, ss) { | 2054 | for_each_root_subsys(root, ss) { |
2058 | if (ss->can_attach) { | 2055 | if (ss->can_attach) { |
2059 | retval = ss->can_attach(cgrp, &tset); | 2056 | retval = ss->can_attach(cgrp, &tset); |
2060 | if (retval) { | 2057 | if (retval) { |
@@ -2091,7 +2088,7 @@ static int cgroup_attach_task(struct cgroup *cgrp, struct task_struct *tsk, | |||
2091 | /* | 2088 | /* |
2092 | * step 4: do subsystem attach callbacks. | 2089 | * step 4: do subsystem attach callbacks. |
2093 | */ | 2090 | */ |
2094 | for_each_subsys(root, ss) { | 2091 | for_each_root_subsys(root, ss) { |
2095 | if (ss->attach) | 2092 | if (ss->attach) |
2096 | ss->attach(cgrp, &tset); | 2093 | ss->attach(cgrp, &tset); |
2097 | } | 2094 | } |
@@ -2111,7 +2108,7 @@ out_put_css_set_refs: | |||
2111 | } | 2108 | } |
2112 | out_cancel_attach: | 2109 | out_cancel_attach: |
2113 | if (retval) { | 2110 | if (retval) { |
2114 | for_each_subsys(root, ss) { | 2111 | for_each_root_subsys(root, ss) { |
2115 | if (ss == failed_ss) | 2112 | if (ss == failed_ss) |
2116 | break; | 2113 | break; |
2117 | if (ss->cancel_attach) | 2114 | if (ss->cancel_attach) |
@@ -4137,7 +4134,7 @@ static int cgroup_populate_dir(struct cgroup *cgrp, bool base_files, | |||
4137 | } | 4134 | } |
4138 | 4135 | ||
4139 | /* process cftsets of each subsystem */ | 4136 | /* process cftsets of each subsystem */ |
4140 | for_each_subsys(cgrp->root, ss) { | 4137 | for_each_root_subsys(cgrp->root, ss) { |
4141 | struct cftype_set *set; | 4138 | struct cftype_set *set; |
4142 | if (!test_bit(ss->subsys_id, &subsys_mask)) | 4139 | if (!test_bit(ss->subsys_id, &subsys_mask)) |
4143 | continue; | 4140 | continue; |
@@ -4147,7 +4144,7 @@ static int cgroup_populate_dir(struct cgroup *cgrp, bool base_files, | |||
4147 | } | 4144 | } |
4148 | 4145 | ||
4149 | /* This cgroup is ready now */ | 4146 | /* This cgroup is ready now */ |
4150 | for_each_subsys(cgrp->root, ss) { | 4147 | for_each_root_subsys(cgrp->root, ss) { |
4151 | struct cgroup_subsys_state *css = cgrp->subsys[ss->subsys_id]; | 4148 | struct cgroup_subsys_state *css = cgrp->subsys[ss->subsys_id]; |
4152 | /* | 4149 | /* |
4153 | * Update id->css pointer and make this css visible from | 4150 | * Update id->css pointer and make this css visible from |
@@ -4294,7 +4291,7 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry, | |||
4294 | if (test_bit(CGRP_CPUSET_CLONE_CHILDREN, &parent->flags)) | 4291 | if (test_bit(CGRP_CPUSET_CLONE_CHILDREN, &parent->flags)) |
4295 | set_bit(CGRP_CPUSET_CLONE_CHILDREN, &cgrp->flags); | 4292 | set_bit(CGRP_CPUSET_CLONE_CHILDREN, &cgrp->flags); |
4296 | 4293 | ||
4297 | for_each_subsys(root, ss) { | 4294 | for_each_root_subsys(root, ss) { |
4298 | struct cgroup_subsys_state *css; | 4295 | struct cgroup_subsys_state *css; |
4299 | 4296 | ||
4300 | css = ss->css_alloc(cgrp); | 4297 | css = ss->css_alloc(cgrp); |
@@ -4333,14 +4330,14 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry, | |||
4333 | root->number_of_cgroups++; | 4330 | root->number_of_cgroups++; |
4334 | 4331 | ||
4335 | /* each css holds a ref to the cgroup's dentry */ | 4332 | /* each css holds a ref to the cgroup's dentry */ |
4336 | for_each_subsys(root, ss) | 4333 | for_each_root_subsys(root, ss) |
4337 | dget(dentry); | 4334 | dget(dentry); |
4338 | 4335 | ||
4339 | /* hold a ref to the parent's dentry */ | 4336 | /* hold a ref to the parent's dentry */ |
4340 | dget(parent->dentry); | 4337 | dget(parent->dentry); |
4341 | 4338 | ||
4342 | /* creation succeeded, notify subsystems */ | 4339 | /* creation succeeded, notify subsystems */ |
4343 | for_each_subsys(root, ss) { | 4340 | for_each_root_subsys(root, ss) { |
4344 | err = online_css(ss, cgrp); | 4341 | err = online_css(ss, cgrp); |
4345 | if (err) | 4342 | if (err) |
4346 | goto err_destroy; | 4343 | goto err_destroy; |
@@ -4365,7 +4362,7 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry, | |||
4365 | return 0; | 4362 | return 0; |
4366 | 4363 | ||
4367 | err_free_all: | 4364 | err_free_all: |
4368 | for_each_subsys(root, ss) { | 4365 | for_each_root_subsys(root, ss) { |
4369 | struct cgroup_subsys_state *css = cgrp->subsys[ss->subsys_id]; | 4366 | struct cgroup_subsys_state *css = cgrp->subsys[ss->subsys_id]; |
4370 | 4367 | ||
4371 | if (css) { | 4368 | if (css) { |
@@ -4478,7 +4475,7 @@ static int cgroup_destroy_locked(struct cgroup *cgrp) | |||
4478 | * be killed. | 4475 | * be killed. |
4479 | */ | 4476 | */ |
4480 | atomic_set(&cgrp->css_kill_cnt, 1); | 4477 | atomic_set(&cgrp->css_kill_cnt, 1); |
4481 | for_each_subsys(cgrp->root, ss) { | 4478 | for_each_root_subsys(cgrp->root, ss) { |
4482 | struct cgroup_subsys_state *css = cgrp->subsys[ss->subsys_id]; | 4479 | struct cgroup_subsys_state *css = cgrp->subsys[ss->subsys_id]; |
4483 | 4480 | ||
4484 | /* | 4481 | /* |
@@ -4552,7 +4549,7 @@ static void cgroup_offline_fn(struct work_struct *work) | |||
4552 | * css_tryget() is guaranteed to fail now. Tell subsystems to | 4549 | * css_tryget() is guaranteed to fail now. Tell subsystems to |
4553 | * initate destruction. | 4550 | * initate destruction. |
4554 | */ | 4551 | */ |
4555 | for_each_subsys(cgrp->root, ss) | 4552 | for_each_root_subsys(cgrp->root, ss) |
4556 | offline_css(ss, cgrp); | 4553 | offline_css(ss, cgrp); |
4557 | 4554 | ||
4558 | /* | 4555 | /* |
@@ -4562,7 +4559,7 @@ static void cgroup_offline_fn(struct work_struct *work) | |||
4562 | * whenever that may be, the extra dentry ref is put so that dentry | 4559 | * whenever that may be, the extra dentry ref is put so that dentry |
4563 | * destruction happens only after all css's are released. | 4560 | * destruction happens only after all css's are released. |
4564 | */ | 4561 | */ |
4565 | for_each_subsys(cgrp->root, ss) | 4562 | for_each_root_subsys(cgrp->root, ss) |
4566 | css_put(cgrp->subsys[ss->subsys_id]); | 4563 | css_put(cgrp->subsys[ss->subsys_id]); |
4567 | 4564 | ||
4568 | /* delete this cgroup from parent->children */ | 4565 | /* delete this cgroup from parent->children */ |
@@ -4967,7 +4964,7 @@ int proc_cgroup_show(struct seq_file *m, void *v) | |||
4967 | int count = 0; | 4964 | int count = 0; |
4968 | 4965 | ||
4969 | seq_printf(m, "%d:", root->hierarchy_id); | 4966 | seq_printf(m, "%d:", root->hierarchy_id); |
4970 | for_each_subsys(root, ss) | 4967 | for_each_root_subsys(root, ss) |
4971 | seq_printf(m, "%s%s", count++ ? "," : "", ss->name); | 4968 | seq_printf(m, "%s%s", count++ ? "," : "", ss->name); |
4972 | if (strlen(root->name)) | 4969 | if (strlen(root->name)) |
4973 | seq_printf(m, "%sname=%s", count ? "," : "", | 4970 | seq_printf(m, "%sname=%s", count ? "," : "", |