cgroup: add cgroup_subsys->css_released()
authorTejun Heo <tj@kernel.org>
Tue, 18 Nov 2014 07:49:51 +0000 (02:49 -0500)
committerTejun Heo <tj@kernel.org>
Tue, 18 Nov 2014 07:49:51 +0000 (02:49 -0500)
Add a new cgroup subsys callback css_released().  This is called when
the reference count of the css (cgroup_subsys_state) reaches zero
before RCU scheduling free.

Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Zefan Li <lizefan@huawei.com>
include/linux/cgroup.h
kernel/cgroup.c

index 1d51968890480bdbca29d576769a6565ba7544a2..e717a39f22eabc8795f5e7ed397fb4a45430ff36 100644 (file)
@@ -612,6 +612,7 @@ struct cgroup_subsys {
        struct cgroup_subsys_state *(*css_alloc)(struct cgroup_subsys_state *parent_css);
        int (*css_online)(struct cgroup_subsys_state *css);
        void (*css_offline)(struct cgroup_subsys_state *css);
+       void (*css_released)(struct cgroup_subsys_state *css);
        void (*css_free)(struct cgroup_subsys_state *css);
        void (*css_reset)(struct cgroup_subsys_state *css);
 
index dffa54041d4a3544b0b6112de1a6363bbcd54935..c8558693102b906f6dedf6579b9212dafcd855b2 100644 (file)
@@ -4380,6 +4380,8 @@ static void css_release_work_fn(struct work_struct *work)
        if (ss) {
                /* css release path */
                cgroup_idr_remove(&ss->css_idr, css->id);
+               if (ss->css_released)
+                       ss->css_released(css);
        } else {
                /* cgroup release path */
                cgroup_idr_remove(&cgrp->root->cgroup_idr, cgrp->id);