• T
    cgroup: RCU protect each cgroup_subsys_state release · 0c21ead1
    Tejun Heo 提交于
    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.  Most of the destruction path has been decoupled but the
    actual free of css still depends on cgroup free path.
    
    When all css refs are drained, css_release() kicks off
    css_free_work_fn() which puts the cgroup.  When the cgroup refcnt
    reaches zero, cgroup_diput() is invoked which in turn schedules RCU
    free of the cgroup.  After a grace period, all css's are freed along
    with the cgroup itself.
    
    This patch moves the RCU grace period and css freeing from cgroup
    release path to css release path.  css_release(), instead of kicking
    off css_free_work_fn() directly, schedules RCU callback
    css_free_rcu_fn() which in turn kicks off css_free_work_fn() after a
    RCU grace period.  css_free_work_fn() is updated to free the css
    directly.
    
    The five-way punting - percpu ref kill confirmation, a work item,
    percpu ref release, RCU grace period, and again a work item - is quite
    hairy but the work items are there only to provide process context and
    the actual sequence is kill confirm -> release -> RCU free, which
    isn't simple but not too crazy.
    
    This removes cgroup_css() usage after offline_css() allowing clearing
    cgroup->subsys[] from offline_css(), which makes it consistent with
    online_css() and brings it closer to proper lifetime management for
    individual css's.
    Signed-off-by: NTejun Heo <tj@kernel.org>
    Acked-by: NLi Zefan <lizefan@huawei.com>
    0c21ead1
cgroup.c 157.5 KB