cgroup: s/for_each_subsys()/for_each_root_subsys()/
for_each_subsys() walks over subsystems attached to a hierarchy and we're gonna add iterators which walk over all available subsystems. Rename for_each_subsys() to for_each_root_subsys() so that it's more appropriately named and for_each_subsys() can be used to iterate all subsystems. While at it, remove unnecessary underbar prefix from macro arguments, put them inside parentheses, and adjust indentation for the two for_each_*() macros. This patch is purely cosmetic. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Li Zefan <lizefan@huawei.com>
This commit is contained in:
parent
b326f9d0db
commit
5549c49791
1 changed files with 22 additions and 25 deletions
|
@ -259,16 +259,13 @@ static int notify_on_release(const struct cgroup *cgrp)
|
||||||
return test_bit(CGRP_NOTIFY_ON_RELEASE, &cgrp->flags);
|
return test_bit(CGRP_NOTIFY_ON_RELEASE, &cgrp->flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* iterate each subsystem attached to a hierarchy */
|
||||||
* for_each_subsys() allows you to iterate on each subsystem attached to
|
#define for_each_root_subsys(root, ss) \
|
||||||
* an active hierarchy
|
list_for_each_entry((ss), &(root)->subsys_list, sibling)
|
||||||
*/
|
|
||||||
#define for_each_subsys(_root, _ss) \
|
|
||||||
list_for_each_entry(_ss, &_root->subsys_list, sibling)
|
|
||||||
|
|
||||||
/* for_each_active_root() allows you to iterate across the active hierarchies */
|
/* iterate across the active hierarchies */
|
||||||
#define for_each_active_root(_root) \
|
#define for_each_active_root(root) \
|
||||||
list_for_each_entry(_root, &cgroup_roots, root_list)
|
list_for_each_entry((root), &cgroup_roots, root_list)
|
||||||
|
|
||||||
static inline struct cgroup *__d_cgrp(struct dentry *dentry)
|
static inline struct cgroup *__d_cgrp(struct dentry *dentry)
|
||||||
{
|
{
|
||||||
|
@ -828,7 +825,7 @@ static void cgroup_free_fn(struct work_struct *work)
|
||||||
/*
|
/*
|
||||||
* Release the subsystem state objects.
|
* Release the subsystem state objects.
|
||||||
*/
|
*/
|
||||||
for_each_subsys(cgrp->root, ss)
|
for_each_root_subsys(cgrp->root, ss)
|
||||||
ss->css_free(cgrp);
|
ss->css_free(cgrp);
|
||||||
|
|
||||||
cgrp->root->number_of_cgroups--;
|
cgrp->root->number_of_cgroups--;
|
||||||
|
@ -944,7 +941,7 @@ static void cgroup_clear_directory(struct dentry *dir, bool base_files,
|
||||||
struct cgroup *cgrp = __d_cgrp(dir);
|
struct cgroup *cgrp = __d_cgrp(dir);
|
||||||
struct cgroup_subsys *ss;
|
struct cgroup_subsys *ss;
|
||||||
|
|
||||||
for_each_subsys(cgrp->root, ss) {
|
for_each_root_subsys(cgrp->root, ss) {
|
||||||
struct cftype_set *set;
|
struct cftype_set *set;
|
||||||
if (!test_bit(ss->subsys_id, &subsys_mask))
|
if (!test_bit(ss->subsys_id, &subsys_mask))
|
||||||
continue;
|
continue;
|
||||||
|
@ -1078,7 +1075,7 @@ static int cgroup_show_options(struct seq_file *seq, struct dentry *dentry)
|
||||||
struct cgroup_subsys *ss;
|
struct cgroup_subsys *ss;
|
||||||
|
|
||||||
mutex_lock(&cgroup_root_mutex);
|
mutex_lock(&cgroup_root_mutex);
|
||||||
for_each_subsys(root, ss)
|
for_each_root_subsys(root, ss)
|
||||||
seq_printf(seq, ",%s", ss->name);
|
seq_printf(seq, ",%s", ss->name);
|
||||||
if (root->flags & CGRP_ROOT_SANE_BEHAVIOR)
|
if (root->flags & CGRP_ROOT_SANE_BEHAVIOR)
|
||||||
seq_puts(seq, ",sane_behavior");
|
seq_puts(seq, ",sane_behavior");
|
||||||
|
@ -2054,7 +2051,7 @@ static int cgroup_attach_task(struct cgroup *cgrp, struct task_struct *tsk,
|
||||||
/*
|
/*
|
||||||
* step 1: check that we can legitimately attach to the cgroup.
|
* step 1: check that we can legitimately attach to the cgroup.
|
||||||
*/
|
*/
|
||||||
for_each_subsys(root, ss) {
|
for_each_root_subsys(root, ss) {
|
||||||
if (ss->can_attach) {
|
if (ss->can_attach) {
|
||||||
retval = ss->can_attach(cgrp, &tset);
|
retval = ss->can_attach(cgrp, &tset);
|
||||||
if (retval) {
|
if (retval) {
|
||||||
|
@ -2091,7 +2088,7 @@ static int cgroup_attach_task(struct cgroup *cgrp, struct task_struct *tsk,
|
||||||
/*
|
/*
|
||||||
* step 4: do subsystem attach callbacks.
|
* step 4: do subsystem attach callbacks.
|
||||||
*/
|
*/
|
||||||
for_each_subsys(root, ss) {
|
for_each_root_subsys(root, ss) {
|
||||||
if (ss->attach)
|
if (ss->attach)
|
||||||
ss->attach(cgrp, &tset);
|
ss->attach(cgrp, &tset);
|
||||||
}
|
}
|
||||||
|
@ -2111,7 +2108,7 @@ out_put_css_set_refs:
|
||||||
}
|
}
|
||||||
out_cancel_attach:
|
out_cancel_attach:
|
||||||
if (retval) {
|
if (retval) {
|
||||||
for_each_subsys(root, ss) {
|
for_each_root_subsys(root, ss) {
|
||||||
if (ss == failed_ss)
|
if (ss == failed_ss)
|
||||||
break;
|
break;
|
||||||
if (ss->cancel_attach)
|
if (ss->cancel_attach)
|
||||||
|
@ -4137,7 +4134,7 @@ static int cgroup_populate_dir(struct cgroup *cgrp, bool base_files,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* process cftsets of each subsystem */
|
/* process cftsets of each subsystem */
|
||||||
for_each_subsys(cgrp->root, ss) {
|
for_each_root_subsys(cgrp->root, ss) {
|
||||||
struct cftype_set *set;
|
struct cftype_set *set;
|
||||||
if (!test_bit(ss->subsys_id, &subsys_mask))
|
if (!test_bit(ss->subsys_id, &subsys_mask))
|
||||||
continue;
|
continue;
|
||||||
|
@ -4147,7 +4144,7 @@ static int cgroup_populate_dir(struct cgroup *cgrp, bool base_files,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This cgroup is ready now */
|
/* This cgroup is ready now */
|
||||||
for_each_subsys(cgrp->root, ss) {
|
for_each_root_subsys(cgrp->root, ss) {
|
||||||
struct cgroup_subsys_state *css = cgrp->subsys[ss->subsys_id];
|
struct cgroup_subsys_state *css = cgrp->subsys[ss->subsys_id];
|
||||||
/*
|
/*
|
||||||
* Update id->css pointer and make this css visible from
|
* Update id->css pointer and make this css visible from
|
||||||
|
@ -4294,7 +4291,7 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry,
|
||||||
if (test_bit(CGRP_CPUSET_CLONE_CHILDREN, &parent->flags))
|
if (test_bit(CGRP_CPUSET_CLONE_CHILDREN, &parent->flags))
|
||||||
set_bit(CGRP_CPUSET_CLONE_CHILDREN, &cgrp->flags);
|
set_bit(CGRP_CPUSET_CLONE_CHILDREN, &cgrp->flags);
|
||||||
|
|
||||||
for_each_subsys(root, ss) {
|
for_each_root_subsys(root, ss) {
|
||||||
struct cgroup_subsys_state *css;
|
struct cgroup_subsys_state *css;
|
||||||
|
|
||||||
css = ss->css_alloc(cgrp);
|
css = ss->css_alloc(cgrp);
|
||||||
|
@ -4333,14 +4330,14 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry,
|
||||||
root->number_of_cgroups++;
|
root->number_of_cgroups++;
|
||||||
|
|
||||||
/* each css holds a ref to the cgroup's dentry */
|
/* each css holds a ref to the cgroup's dentry */
|
||||||
for_each_subsys(root, ss)
|
for_each_root_subsys(root, ss)
|
||||||
dget(dentry);
|
dget(dentry);
|
||||||
|
|
||||||
/* hold a ref to the parent's dentry */
|
/* hold a ref to the parent's dentry */
|
||||||
dget(parent->dentry);
|
dget(parent->dentry);
|
||||||
|
|
||||||
/* creation succeeded, notify subsystems */
|
/* creation succeeded, notify subsystems */
|
||||||
for_each_subsys(root, ss) {
|
for_each_root_subsys(root, ss) {
|
||||||
err = online_css(ss, cgrp);
|
err = online_css(ss, cgrp);
|
||||||
if (err)
|
if (err)
|
||||||
goto err_destroy;
|
goto err_destroy;
|
||||||
|
@ -4365,7 +4362,7 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry,
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err_free_all:
|
err_free_all:
|
||||||
for_each_subsys(root, ss) {
|
for_each_root_subsys(root, ss) {
|
||||||
struct cgroup_subsys_state *css = cgrp->subsys[ss->subsys_id];
|
struct cgroup_subsys_state *css = cgrp->subsys[ss->subsys_id];
|
||||||
|
|
||||||
if (css) {
|
if (css) {
|
||||||
|
@ -4478,7 +4475,7 @@ static int cgroup_destroy_locked(struct cgroup *cgrp)
|
||||||
* be killed.
|
* be killed.
|
||||||
*/
|
*/
|
||||||
atomic_set(&cgrp->css_kill_cnt, 1);
|
atomic_set(&cgrp->css_kill_cnt, 1);
|
||||||
for_each_subsys(cgrp->root, ss) {
|
for_each_root_subsys(cgrp->root, ss) {
|
||||||
struct cgroup_subsys_state *css = cgrp->subsys[ss->subsys_id];
|
struct cgroup_subsys_state *css = cgrp->subsys[ss->subsys_id];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -4552,7 +4549,7 @@ static void cgroup_offline_fn(struct work_struct *work)
|
||||||
* css_tryget() is guaranteed to fail now. Tell subsystems to
|
* css_tryget() is guaranteed to fail now. Tell subsystems to
|
||||||
* initate destruction.
|
* initate destruction.
|
||||||
*/
|
*/
|
||||||
for_each_subsys(cgrp->root, ss)
|
for_each_root_subsys(cgrp->root, ss)
|
||||||
offline_css(ss, cgrp);
|
offline_css(ss, cgrp);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -4562,7 +4559,7 @@ static void cgroup_offline_fn(struct work_struct *work)
|
||||||
* whenever that may be, the extra dentry ref is put so that dentry
|
* whenever that may be, the extra dentry ref is put so that dentry
|
||||||
* destruction happens only after all css's are released.
|
* destruction happens only after all css's are released.
|
||||||
*/
|
*/
|
||||||
for_each_subsys(cgrp->root, ss)
|
for_each_root_subsys(cgrp->root, ss)
|
||||||
css_put(cgrp->subsys[ss->subsys_id]);
|
css_put(cgrp->subsys[ss->subsys_id]);
|
||||||
|
|
||||||
/* delete this cgroup from parent->children */
|
/* delete this cgroup from parent->children */
|
||||||
|
@ -4967,7 +4964,7 @@ int proc_cgroup_show(struct seq_file *m, void *v)
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
seq_printf(m, "%d:", root->hierarchy_id);
|
seq_printf(m, "%d:", root->hierarchy_id);
|
||||||
for_each_subsys(root, ss)
|
for_each_root_subsys(root, ss)
|
||||||
seq_printf(m, "%s%s", count++ ? "," : "", ss->name);
|
seq_printf(m, "%s%s", count++ ? "," : "", ss->name);
|
||||||
if (strlen(root->name))
|
if (strlen(root->name))
|
||||||
seq_printf(m, "%sname=%s", count ? "," : "",
|
seq_printf(m, "%sname=%s", count ? "," : "",
|
||||||
|
|
Loading…
Reference in a new issue