cgroup: make cgroup_drain_offline() and cgroup_apply_control_{disable|enable}() recursive
authorTejun Heo <tj@kernel.org>
Thu, 3 Mar 2016 14:57:59 +0000 (09:57 -0500)
committerTejun Heo <tj@kernel.org>
Thu, 3 Mar 2016 14:57:59 +0000 (09:57 -0500)
commitce3f1d9d19371045981a64815227bab822554878
tree4c4693697c3d07537ec53f8afe4b4e4d1aaa2179
parentbdb53bd797dcef46d1a252b9529f8fd511bf714c
cgroup: make cgroup_drain_offline() and cgroup_apply_control_{disable|enable}() recursive

The three factored out css management operations -
cgroup_drain_offline() and cgroup_apply_control_{disable|enable}() -
only depend on the current state of the target cgroups and idempotent
and thus can be easily made to operate on the subtree instead of the
immediate children.

This patch introduces the iterators which walk live subtree and
converts the three functions to operate on the subtree including self
instead of the children.  While this leads to spurious walking and be
slightly more expensive, it will allow them to be used for wider scope
of operations.

Note that cgroup_drain_offline() now tests for whether a css is dying
before trying to drain it.  This is to avoid trying to drain live
csses as there can be mix of live and dying csses in a subtree unlike
children of the same parent.

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