diff options
author | Tejun Heo <tj@kernel.org> | 2013-08-13 20:22:51 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2013-08-13 20:22:51 -0400 |
commit | 3c14f8b44fafaa60519440bea1591e495b928327 (patch) | |
tree | 98da4ec6500a63c3c8f0aff62eaa6fcfe3ace0eb | |
parent | edae0c3358947f8be5ca99f762d89e0c38e1f5d5 (diff) |
cgroup: move subsys file removal to kill_css()
With the planned unified hierarchy, individual css's will be created
and destroyed dynamically across the lifetime of a cgroup. To enable
such usages, css destruction is being decoupled from cgroup
destruction. This patch moves subsys file removal from
cgroup_destroy_locked() to kill_css().
While this changes the order of destruction operations, the changes
shouldn't be noticeable to cgroup subsystems or userland.
Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Li Zefan <lizefan@huawei.com>
-rw-r--r-- | kernel/cgroup.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 7b7575f3119c..3137e38995b0 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
@@ -4599,13 +4599,15 @@ static void css_killed_ref_fn(struct percpu_ref *ref) | |||
4599 | * kill_css - destroy a css | 4599 | * kill_css - destroy a css |
4600 | * @css: css to destroy | 4600 | * @css: css to destroy |
4601 | * | 4601 | * |
4602 | * This function initiates destruction of @css by putting its base | 4602 | * This function initiates destruction of @css by removing cgroup interface |
4603 | * reference. ->css_offline() will be invoked asynchronously once | 4603 | * files and putting its base reference. ->css_offline() will be invoked |
4604 | * css_tryget() is guaranteed to fail and when the reference count reaches | 4604 | * asynchronously once css_tryget() is guaranteed to fail and when the |
4605 | * zero, @css will be released. | 4605 | * reference count reaches zero, @css will be released. |
4606 | */ | 4606 | */ |
4607 | static void kill_css(struct cgroup_subsys_state *css) | 4607 | static void kill_css(struct cgroup_subsys_state *css) |
4608 | { | 4608 | { |
4609 | cgroup_clear_dir(css->cgroup, 1 << css->ss->subsys_id); | ||
4610 | |||
4609 | /* | 4611 | /* |
4610 | * Killing would put the base ref, but we need to keep it alive | 4612 | * Killing would put the base ref, but we need to keep it alive |
4611 | * until after ->css_offline(). | 4613 | * until after ->css_offline(). |
@@ -4703,10 +4705,10 @@ static int cgroup_destroy_locked(struct cgroup *cgrp) | |||
4703 | cgroup_destroy_css_killed(cgrp); | 4705 | cgroup_destroy_css_killed(cgrp); |
4704 | 4706 | ||
4705 | /* | 4707 | /* |
4706 | * Clear and remove @cgrp directory. The removal puts the base ref | 4708 | * Clear the base files and remove @cgrp directory. The removal |
4707 | * but we aren't quite done with @cgrp yet, so hold onto it. | 4709 | * puts the base ref but we aren't quite done with @cgrp yet, so |
4710 | * hold onto it. | ||
4708 | */ | 4711 | */ |
4709 | cgroup_clear_dir(cgrp, cgrp->root->subsys_mask); | ||
4710 | cgroup_addrm_files(cgrp, cgroup_base_files, false); | 4712 | cgroup_addrm_files(cgrp, cgroup_base_files, false); |
4711 | dget(d); | 4713 | dget(d); |
4712 | cgroup_d_remove_dir(d); | 4714 | cgroup_d_remove_dir(d); |