cgroup: combine cgroup_mutex locking and offline css draining
authorTejun Heo <tj@kernel.org>
Thu, 3 Mar 2016 14:58:00 +0000 (09:58 -0500)
committerTejun Heo <tj@kernel.org>
Thu, 3 Mar 2016 14:58:00 +0000 (09:58 -0500)
commit945ba1996888809cf510a8da000a9c20a9fab5ad
tree4bf5e7a11fbb4c80148c53c77be5105f131cf5a0
parentf7b2814bb9b6cb1d69333e1592c702260fcb4184
cgroup: combine cgroup_mutex locking and offline css draining

cgroup_drain_offline() is used to wait for csses being offlined to
uninstall itself from cgroup->subsys[] array so that new csses can be
installed.  The function's only user, cgroup_subtree_control_write(),
calls it after performing some checks and restarts the whole process
via restart_syscall() if draining has to release cgroup_mutex to wait.

This can be simplified by draining before other synchronized
operations so that there's nothing to restart.  This patch converts
cgroup_drain_offline() to cgroup_lock_and_drain_offline() which
performs both locking and draining and updates cgroup_kn_lock_live()
use it instead of cgroup_mutex() if requested.  This combined locking
and draining operations are easier to use and less error-prone.

While at it, add WARNs in control_apply functions which triggers if
the subtree isn't properly drained.

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