aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/cgroup.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2013-08-13 20:22:50 -0400
committerTejun Heo <tj@kernel.org>2013-08-13 20:22:50 -0400
commit223dbc38d2a8745a93749dc75ed909e274ce075d (patch)
tree1b9fef44b8dca745dc37e5c98be8fe8e190b9691 /kernel/cgroup.c
parentae7f164a09408bf21ab3c82a9e80a3ff37aa9e3e (diff)
cgroup: bounce cgroup_subsys_state ref kill confirmation to a work item
css (cgroup_subsys_state) offlining, which requires process context, will be moved to ref kill confirmation. In preparation, bounce css_killed handling through css->destroy_work. css_ref_killed_fn() is renamed to css_killed_ref_fn() so that it's consistent with the new css_killed_work_fn(). This patch adds an additional work item bouncing but doesn't change the actual logic. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Li Zefan <lizefan@huawei.com>
Diffstat (limited to 'kernel/cgroup.c')
-rw-r--r--kernel/cgroup.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index b9f736c3b36d..398ffbbee32f 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -4555,12 +4555,27 @@ static void cgroup_css_killed(struct cgroup *cgrp)
4555 schedule_work(&cgrp->destroy_work); 4555 schedule_work(&cgrp->destroy_work);
4556} 4556}
4557 4557
4558static void css_ref_killed_fn(struct percpu_ref *ref) 4558/*
4559 * This is called when the refcnt of a css is confirmed to be killed.
4560 * css_tryget() is now guaranteed to fail.
4561 */
4562static void css_killed_work_fn(struct work_struct *work)
4563{
4564 struct cgroup_subsys_state *css =
4565 container_of(work, struct cgroup_subsys_state, destroy_work);
4566 struct cgroup *cgrp = css->cgroup;
4567
4568 cgroup_css_killed(cgrp);
4569}
4570
4571/* css kill confirmation processing requires process context, bounce */
4572static void css_killed_ref_fn(struct percpu_ref *ref)
4559{ 4573{
4560 struct cgroup_subsys_state *css = 4574 struct cgroup_subsys_state *css =
4561 container_of(ref, struct cgroup_subsys_state, refcnt); 4575 container_of(ref, struct cgroup_subsys_state, refcnt);
4562 4576
4563 cgroup_css_killed(css->cgroup); 4577 INIT_WORK(&css->destroy_work, css_killed_work_fn);
4578 schedule_work(&css->destroy_work);
4564} 4579}
4565 4580
4566/** 4581/**
@@ -4634,7 +4649,7 @@ static int cgroup_destroy_locked(struct cgroup *cgrp)
4634 percpu_ref_get(&css->refcnt); 4649 percpu_ref_get(&css->refcnt);
4635 4650
4636 atomic_inc(&cgrp->css_kill_cnt); 4651 atomic_inc(&cgrp->css_kill_cnt);
4637 percpu_ref_kill_and_confirm(&css->refcnt, css_ref_killed_fn); 4652 percpu_ref_kill_and_confirm(&css->refcnt, css_killed_ref_fn);
4638 } 4653 }
4639 cgroup_css_killed(cgrp); 4654 cgroup_css_killed(cgrp);
4640 4655