diff options
author | Li Zefan <lizf@cn.fujitsu.com> | 2012-01-31 00:47:36 -0500 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2012-02-02 12:20:22 -0500 |
commit | 761b3ef50e1c2649cffbfa67a4dcb2dcdb7982ed (patch) | |
tree | 67ab6a9a2520811c9c0b4d70d1c19b4bfca16237 /kernel/cgroup.c | |
parent | 61d1d219c4c0761059236a46867bc49943c4d29d (diff) |
cgroup: remove cgroup_subsys argument from callbacks
The argument is not used at all, and it's not necessary, because
a specific callback handler of course knows which subsys it
belongs to.
Now only ->pupulate() takes this argument, because the handlers of
this callback always call cgroup_add_file()/cgroup_add_files().
So we reduce a few lines of code, though the shrinking of object size
is minimal.
16 files changed, 113 insertions(+), 162 deletions(-)
text data bss dec hex filename
5486240 656987 7039960 13183187 c928d3 vmlinux.o.orig
5486170 656987 7039960 13183117 c9288d vmlinux.o
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'kernel/cgroup.c')
-rw-r--r-- | kernel/cgroup.c | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 43a224f167b5..865d89a580c7 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
@@ -818,7 +818,7 @@ static int cgroup_call_pre_destroy(struct cgroup *cgrp) | |||
818 | 818 | ||
819 | for_each_subsys(cgrp->root, ss) | 819 | for_each_subsys(cgrp->root, ss) |
820 | if (ss->pre_destroy) { | 820 | if (ss->pre_destroy) { |
821 | ret = ss->pre_destroy(ss, cgrp); | 821 | ret = ss->pre_destroy(cgrp); |
822 | if (ret) | 822 | if (ret) |
823 | break; | 823 | break; |
824 | } | 824 | } |
@@ -846,7 +846,7 @@ static void cgroup_diput(struct dentry *dentry, struct inode *inode) | |||
846 | * Release the subsystem state objects. | 846 | * Release the subsystem state objects. |
847 | */ | 847 | */ |
848 | for_each_subsys(cgrp->root, ss) | 848 | for_each_subsys(cgrp->root, ss) |
849 | ss->destroy(ss, cgrp); | 849 | ss->destroy(cgrp); |
850 | 850 | ||
851 | cgrp->root->number_of_cgroups--; | 851 | cgrp->root->number_of_cgroups--; |
852 | mutex_unlock(&cgroup_mutex); | 852 | mutex_unlock(&cgroup_mutex); |
@@ -1015,7 +1015,7 @@ static int rebind_subsystems(struct cgroupfs_root *root, | |||
1015 | list_move(&ss->sibling, &root->subsys_list); | 1015 | list_move(&ss->sibling, &root->subsys_list); |
1016 | ss->root = root; | 1016 | ss->root = root; |
1017 | if (ss->bind) | 1017 | if (ss->bind) |
1018 | ss->bind(ss, cgrp); | 1018 | ss->bind(cgrp); |
1019 | mutex_unlock(&ss->hierarchy_mutex); | 1019 | mutex_unlock(&ss->hierarchy_mutex); |
1020 | /* refcount was already taken, and we're keeping it */ | 1020 | /* refcount was already taken, and we're keeping it */ |
1021 | } else if (bit & removed_bits) { | 1021 | } else if (bit & removed_bits) { |
@@ -1025,7 +1025,7 @@ static int rebind_subsystems(struct cgroupfs_root *root, | |||
1025 | BUG_ON(cgrp->subsys[i]->cgroup != cgrp); | 1025 | BUG_ON(cgrp->subsys[i]->cgroup != cgrp); |
1026 | mutex_lock(&ss->hierarchy_mutex); | 1026 | mutex_lock(&ss->hierarchy_mutex); |
1027 | if (ss->bind) | 1027 | if (ss->bind) |
1028 | ss->bind(ss, dummytop); | 1028 | ss->bind(dummytop); |
1029 | dummytop->subsys[i]->cgroup = dummytop; | 1029 | dummytop->subsys[i]->cgroup = dummytop; |
1030 | cgrp->subsys[i] = NULL; | 1030 | cgrp->subsys[i] = NULL; |
1031 | subsys[i]->root = &rootnode; | 1031 | subsys[i]->root = &rootnode; |
@@ -1908,7 +1908,7 @@ int cgroup_attach_task(struct cgroup *cgrp, struct task_struct *tsk) | |||
1908 | 1908 | ||
1909 | for_each_subsys(root, ss) { | 1909 | for_each_subsys(root, ss) { |
1910 | if (ss->can_attach) { | 1910 | if (ss->can_attach) { |
1911 | retval = ss->can_attach(ss, cgrp, &tset); | 1911 | retval = ss->can_attach(cgrp, &tset); |
1912 | if (retval) { | 1912 | if (retval) { |
1913 | /* | 1913 | /* |
1914 | * Remember on which subsystem the can_attach() | 1914 | * Remember on which subsystem the can_attach() |
@@ -1932,7 +1932,7 @@ int cgroup_attach_task(struct cgroup *cgrp, struct task_struct *tsk) | |||
1932 | 1932 | ||
1933 | for_each_subsys(root, ss) { | 1933 | for_each_subsys(root, ss) { |
1934 | if (ss->attach) | 1934 | if (ss->attach) |
1935 | ss->attach(ss, cgrp, &tset); | 1935 | ss->attach(cgrp, &tset); |
1936 | } | 1936 | } |
1937 | 1937 | ||
1938 | synchronize_rcu(); | 1938 | synchronize_rcu(); |
@@ -1954,7 +1954,7 @@ out: | |||
1954 | */ | 1954 | */ |
1955 | break; | 1955 | break; |
1956 | if (ss->cancel_attach) | 1956 | if (ss->cancel_attach) |
1957 | ss->cancel_attach(ss, cgrp, &tset); | 1957 | ss->cancel_attach(cgrp, &tset); |
1958 | } | 1958 | } |
1959 | } | 1959 | } |
1960 | return retval; | 1960 | return retval; |
@@ -2067,7 +2067,7 @@ static int cgroup_attach_proc(struct cgroup *cgrp, struct task_struct *leader) | |||
2067 | */ | 2067 | */ |
2068 | for_each_subsys(root, ss) { | 2068 | for_each_subsys(root, ss) { |
2069 | if (ss->can_attach) { | 2069 | if (ss->can_attach) { |
2070 | retval = ss->can_attach(ss, cgrp, &tset); | 2070 | retval = ss->can_attach(cgrp, &tset); |
2071 | if (retval) { | 2071 | if (retval) { |
2072 | failed_ss = ss; | 2072 | failed_ss = ss; |
2073 | goto out_cancel_attach; | 2073 | goto out_cancel_attach; |
@@ -2104,7 +2104,7 @@ static int cgroup_attach_proc(struct cgroup *cgrp, struct task_struct *leader) | |||
2104 | */ | 2104 | */ |
2105 | for_each_subsys(root, ss) { | 2105 | for_each_subsys(root, ss) { |
2106 | if (ss->attach) | 2106 | if (ss->attach) |
2107 | ss->attach(ss, cgrp, &tset); | 2107 | ss->attach(cgrp, &tset); |
2108 | } | 2108 | } |
2109 | 2109 | ||
2110 | /* | 2110 | /* |
@@ -2128,7 +2128,7 @@ out_cancel_attach: | |||
2128 | if (ss == failed_ss) | 2128 | if (ss == failed_ss) |
2129 | break; | 2129 | break; |
2130 | if (ss->cancel_attach) | 2130 | if (ss->cancel_attach) |
2131 | ss->cancel_attach(ss, cgrp, &tset); | 2131 | ss->cancel_attach(cgrp, &tset); |
2132 | } | 2132 | } |
2133 | } | 2133 | } |
2134 | out_free_group_list: | 2134 | out_free_group_list: |
@@ -3756,7 +3756,7 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry, | |||
3756 | set_bit(CGRP_CLONE_CHILDREN, &cgrp->flags); | 3756 | set_bit(CGRP_CLONE_CHILDREN, &cgrp->flags); |
3757 | 3757 | ||
3758 | for_each_subsys(root, ss) { | 3758 | for_each_subsys(root, ss) { |
3759 | struct cgroup_subsys_state *css = ss->create(ss, cgrp); | 3759 | struct cgroup_subsys_state *css = ss->create(cgrp); |
3760 | 3760 | ||
3761 | if (IS_ERR(css)) { | 3761 | if (IS_ERR(css)) { |
3762 | err = PTR_ERR(css); | 3762 | err = PTR_ERR(css); |
@@ -3770,7 +3770,7 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry, | |||
3770 | } | 3770 | } |
3771 | /* At error, ->destroy() callback has to free assigned ID. */ | 3771 | /* At error, ->destroy() callback has to free assigned ID. */ |
3772 | if (clone_children(parent) && ss->post_clone) | 3772 | if (clone_children(parent) && ss->post_clone) |
3773 | ss->post_clone(ss, cgrp); | 3773 | ss->post_clone(cgrp); |
3774 | } | 3774 | } |
3775 | 3775 | ||
3776 | cgroup_lock_hierarchy(root); | 3776 | cgroup_lock_hierarchy(root); |
@@ -3804,7 +3804,7 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry, | |||
3804 | 3804 | ||
3805 | for_each_subsys(root, ss) { | 3805 | for_each_subsys(root, ss) { |
3806 | if (cgrp->subsys[ss->subsys_id]) | 3806 | if (cgrp->subsys[ss->subsys_id]) |
3807 | ss->destroy(ss, cgrp); | 3807 | ss->destroy(cgrp); |
3808 | } | 3808 | } |
3809 | 3809 | ||
3810 | mutex_unlock(&cgroup_mutex); | 3810 | mutex_unlock(&cgroup_mutex); |
@@ -4028,7 +4028,7 @@ static void __init cgroup_init_subsys(struct cgroup_subsys *ss) | |||
4028 | /* Create the top cgroup state for this subsystem */ | 4028 | /* Create the top cgroup state for this subsystem */ |
4029 | list_add(&ss->sibling, &rootnode.subsys_list); | 4029 | list_add(&ss->sibling, &rootnode.subsys_list); |
4030 | ss->root = &rootnode; | 4030 | ss->root = &rootnode; |
4031 | css = ss->create(ss, dummytop); | 4031 | css = ss->create(dummytop); |
4032 | /* We don't handle early failures gracefully */ | 4032 | /* We don't handle early failures gracefully */ |
4033 | BUG_ON(IS_ERR(css)); | 4033 | BUG_ON(IS_ERR(css)); |
4034 | init_cgroup_css(css, ss, dummytop); | 4034 | init_cgroup_css(css, ss, dummytop); |
@@ -4117,7 +4117,7 @@ int __init_or_module cgroup_load_subsys(struct cgroup_subsys *ss) | |||
4117 | * no ss->create seems to need anything important in the ss struct, so | 4117 | * no ss->create seems to need anything important in the ss struct, so |
4118 | * this can happen first (i.e. before the rootnode attachment). | 4118 | * this can happen first (i.e. before the rootnode attachment). |
4119 | */ | 4119 | */ |
4120 | css = ss->create(ss, dummytop); | 4120 | css = ss->create(dummytop); |
4121 | if (IS_ERR(css)) { | 4121 | if (IS_ERR(css)) { |
4122 | /* failure case - need to deassign the subsys[] slot. */ | 4122 | /* failure case - need to deassign the subsys[] slot. */ |
4123 | subsys[i] = NULL; | 4123 | subsys[i] = NULL; |
@@ -4135,7 +4135,7 @@ int __init_or_module cgroup_load_subsys(struct cgroup_subsys *ss) | |||
4135 | int ret = cgroup_init_idr(ss, css); | 4135 | int ret = cgroup_init_idr(ss, css); |
4136 | if (ret) { | 4136 | if (ret) { |
4137 | dummytop->subsys[ss->subsys_id] = NULL; | 4137 | dummytop->subsys[ss->subsys_id] = NULL; |
4138 | ss->destroy(ss, dummytop); | 4138 | ss->destroy(dummytop); |
4139 | subsys[i] = NULL; | 4139 | subsys[i] = NULL; |
4140 | mutex_unlock(&cgroup_mutex); | 4140 | mutex_unlock(&cgroup_mutex); |
4141 | return ret; | 4141 | return ret; |
@@ -4233,7 +4233,7 @@ void cgroup_unload_subsys(struct cgroup_subsys *ss) | |||
4233 | * pointer to find their state. note that this also takes care of | 4233 | * pointer to find their state. note that this also takes care of |
4234 | * freeing the css_id. | 4234 | * freeing the css_id. |
4235 | */ | 4235 | */ |
4236 | ss->destroy(ss, dummytop); | 4236 | ss->destroy(dummytop); |
4237 | dummytop->subsys[ss->subsys_id] = NULL; | 4237 | dummytop->subsys[ss->subsys_id] = NULL; |
4238 | 4238 | ||
4239 | mutex_unlock(&cgroup_mutex); | 4239 | mutex_unlock(&cgroup_mutex); |
@@ -4509,7 +4509,7 @@ void cgroup_fork_callbacks(struct task_struct *child) | |||
4509 | for (i = 0; i < CGROUP_BUILTIN_SUBSYS_COUNT; i++) { | 4509 | for (i = 0; i < CGROUP_BUILTIN_SUBSYS_COUNT; i++) { |
4510 | struct cgroup_subsys *ss = subsys[i]; | 4510 | struct cgroup_subsys *ss = subsys[i]; |
4511 | if (ss->fork) | 4511 | if (ss->fork) |
4512 | ss->fork(ss, child); | 4512 | ss->fork(child); |
4513 | } | 4513 | } |
4514 | } | 4514 | } |
4515 | } | 4515 | } |
@@ -4611,7 +4611,7 @@ void cgroup_exit(struct task_struct *tsk, int run_callbacks) | |||
4611 | struct cgroup *old_cgrp = | 4611 | struct cgroup *old_cgrp = |
4612 | rcu_dereference_raw(cg->subsys[i])->cgroup; | 4612 | rcu_dereference_raw(cg->subsys[i])->cgroup; |
4613 | struct cgroup *cgrp = task_cgroup(tsk, i); | 4613 | struct cgroup *cgrp = task_cgroup(tsk, i); |
4614 | ss->exit(ss, cgrp, old_cgrp, tsk); | 4614 | ss->exit(cgrp, old_cgrp, tsk); |
4615 | } | 4615 | } |
4616 | } | 4616 | } |
4617 | } | 4617 | } |
@@ -5066,8 +5066,7 @@ struct cgroup_subsys_state *cgroup_css_from_dir(struct file *f, int id) | |||
5066 | } | 5066 | } |
5067 | 5067 | ||
5068 | #ifdef CONFIG_CGROUP_DEBUG | 5068 | #ifdef CONFIG_CGROUP_DEBUG |
5069 | static struct cgroup_subsys_state *debug_create(struct cgroup_subsys *ss, | 5069 | static struct cgroup_subsys_state *debug_create(struct cgroup *cont) |
5070 | struct cgroup *cont) | ||
5071 | { | 5070 | { |
5072 | struct cgroup_subsys_state *css = kzalloc(sizeof(*css), GFP_KERNEL); | 5071 | struct cgroup_subsys_state *css = kzalloc(sizeof(*css), GFP_KERNEL); |
5073 | 5072 | ||
@@ -5077,7 +5076,7 @@ static struct cgroup_subsys_state *debug_create(struct cgroup_subsys *ss, | |||
5077 | return css; | 5076 | return css; |
5078 | } | 5077 | } |
5079 | 5078 | ||
5080 | static void debug_destroy(struct cgroup_subsys *ss, struct cgroup *cont) | 5079 | static void debug_destroy(struct cgroup *cont) |
5081 | { | 5080 | { |
5082 | kfree(cont->subsys[debug_subsys_id]); | 5081 | kfree(cont->subsys[debug_subsys_id]); |
5083 | } | 5082 | } |