]> git.baikalelectronics.ru Git - kernel.git/commit
cgroup: fix the async css offline wait logic in cgroup_subtree_control_write()
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)
commit9dbe519246196eeb30328b6bb74999698b7ec6b8
tree8c5312b003c93451dd5a448a58052fa9ca4af6a7
parentfda7222a5de575138df0febb03baf9710c362537
cgroup: fix the async css offline wait logic in cgroup_subtree_control_write()

When a subsystem is offlined, its entry on @cgrp->subsys[] is cleared
asynchronously.  If cgroup_subtree_control_write() is requested to
enable the subsystem again before the entry is cleared, it has to wait
for the previous offlining to finish and clear the @cgrp->subsys[]
entry before trying to enable the subsystem again.

This is currently done while verifying the input enable / disable
parameters.  This used to be correct but 7063370cf313 ("cgroup: make
interface files visible iff enabled on cgroup->subtree_control")
breaks it.  The commit is one of the commits implementing subsystem
dependency.

Through subsystem dependency, some subsystems may be enabled and
disabled implicitly in addition to the explicitly requested ones.  The
actual subsystems to be enabled and disabled are determined during
@css_enable/disable calculation.  The current offline wait logic skips
the ones which are already implicitly enabled and then waits for
subsystems in @enable; however, this misses the subsystems which may
be implicitly enabled through dependency from @enable.  If such
implicitly subsystem hasn't yet finished offlining yet, the function
ends up trying to create a css when its @cgrp->subsys[] slot is
already occupied triggering BUG_ON() in init_and_link_css().

Fix it by moving the wait logic after @css_enable is calculated and
waiting for all the subsystems in @css_enable.  This fixes the above
bug as the mask contains all subsystems which are to be enabled
including the ones enabled through dependencies.

Signed-off-by: Tejun Heo <tj@kernel.org>
Fixes: 7063370cf313 ("cgroup: make interface files visible iff enabled on cgroup->subtree_control")
Acked-by: Zefan Li <lizefan@huawei.com>
kernel/cgroup.c