diff options
author | Tejun Heo <tj@kernel.org> | 2013-08-13 11:01:54 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2013-08-13 11:01:54 -0400 |
commit | 35ef10da65d43211f4cd7e7822cbb3becdfc0ae1 (patch) | |
tree | 93384946eba30c0de1621d5a5895ae64c1583730 | |
parent | 40e93b39cd5b6a347333a95152ce37deef37bbd0 (diff) |
cgroup: rename cgroup_subsys_state->dput_work and its callback function
css (cgroup_subsys_state) will become RCU protected and there will be
two stages which require punting to work item during release. To
prepare for using the work item for multiple times, rename
css->dput_work to css->destroy_work and css_dput_fn() to
css_free_work_fn() and move work item initialization from css init to
right before the actual usage.
This reorganization doesn't introduce any behavior change.
Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Li Zefan <lizefan@huawei.com>
-rw-r--r-- | include/linux/cgroup.h | 2 | ||||
-rw-r--r-- | kernel/cgroup.c | 21 |
2 files changed, 11 insertions, 12 deletions
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h index 8ec5b0f38292..12d66fee26f8 100644 --- a/include/linux/cgroup.h +++ b/include/linux/cgroup.h | |||
@@ -80,7 +80,7 @@ struct cgroup_subsys_state { | |||
80 | struct css_id __rcu *id; | 80 | struct css_id __rcu *id; |
81 | 81 | ||
82 | /* Used to put @cgroup->dentry on the last css_put() */ | 82 | /* Used to put @cgroup->dentry on the last css_put() */ |
83 | struct work_struct dput_work; | 83 | struct work_struct destroy_work; |
84 | }; | 84 | }; |
85 | 85 | ||
86 | /* bits in struct cgroup_subsys_state flags field */ | 86 | /* bits in struct cgroup_subsys_state flags field */ |
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 49ad96ee08e1..0b280978f097 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
@@ -4259,10 +4259,10 @@ err: | |||
4259 | return ret; | 4259 | return ret; |
4260 | } | 4260 | } |
4261 | 4261 | ||
4262 | static void css_dput_fn(struct work_struct *work) | 4262 | static void css_free_work_fn(struct work_struct *work) |
4263 | { | 4263 | { |
4264 | struct cgroup_subsys_state *css = | 4264 | struct cgroup_subsys_state *css = |
4265 | container_of(work, struct cgroup_subsys_state, dput_work); | 4265 | container_of(work, struct cgroup_subsys_state, destroy_work); |
4266 | 4266 | ||
4267 | cgroup_dput(css->cgroup); | 4267 | cgroup_dput(css->cgroup); |
4268 | } | 4268 | } |
@@ -4272,7 +4272,14 @@ static void css_release(struct percpu_ref *ref) | |||
4272 | struct cgroup_subsys_state *css = | 4272 | struct cgroup_subsys_state *css = |
4273 | container_of(ref, struct cgroup_subsys_state, refcnt); | 4273 | container_of(ref, struct cgroup_subsys_state, refcnt); |
4274 | 4274 | ||
4275 | schedule_work(&css->dput_work); | 4275 | /* |
4276 | * css holds an extra ref to @cgrp->dentry which is put on the last | ||
4277 | * css_put(). dput() requires process context, which css_put() may | ||
4278 | * be called without. @css->destroy_work will be used to invoke | ||
4279 | * dput() asynchronously from css_put(). | ||
4280 | */ | ||
4281 | INIT_WORK(&css->destroy_work, css_free_work_fn); | ||
4282 | schedule_work(&css->destroy_work); | ||
4276 | } | 4283 | } |
4277 | 4284 | ||
4278 | static void init_cgroup_css(struct cgroup_subsys_state *css, | 4285 | static void init_cgroup_css(struct cgroup_subsys_state *css, |
@@ -4287,14 +4294,6 @@ static void init_cgroup_css(struct cgroup_subsys_state *css, | |||
4287 | css->flags |= CSS_ROOT; | 4294 | css->flags |= CSS_ROOT; |
4288 | BUG_ON(cgroup_css(cgrp, ss->subsys_id)); | 4295 | BUG_ON(cgroup_css(cgrp, ss->subsys_id)); |
4289 | cgrp->subsys[ss->subsys_id] = css; | 4296 | cgrp->subsys[ss->subsys_id] = css; |
4290 | |||
4291 | /* | ||
4292 | * css holds an extra ref to @cgrp->dentry which is put on the last | ||
4293 | * css_put(). dput() requires process context, which css_put() may | ||
4294 | * be called without. @css->dput_work will be used to invoke | ||
4295 | * dput() asynchronously from css_put(). | ||
4296 | */ | ||
4297 | INIT_WORK(&css->dput_work, css_dput_fn); | ||
4298 | } | 4297 | } |
4299 | 4298 | ||
4300 | /* invoke ->css_online() on a new CSS and mark it online if successful */ | 4299 | /* invoke ->css_online() on a new CSS and mark it online if successful */ |