* [PATCH v2] cgroup: don't destroy the default root
@ 2014-06-04 8:48 Li Zefan
2014-06-05 1:22 ` Tejun Heo
0 siblings, 1 reply; 2+ messages in thread
From: Li Zefan @ 2014-06-04 8:48 UTC (permalink / raw)
To: Tejun Heo; +Cc: LKML, Cgroups
The default root is allocated and initialized at boot phase, so we
shouldn't destroy the default root when it's umounted, otherwise
it will lead to disaster.
Just try mount and then umount the default root, and the kernel will
crash immediately.
v2:
- No need to check for CSS_NO_REF in cgroup_get/put(). (Tejun)
- Better call cgroup_put() for the default root in kill_sb(). (Tejun)
- Add a comment.
Signed-off-by: Li Zefan <lizefan@huawei.com>
---
kernel/cgroup.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index a5f75ac..3f46165 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -1780,8 +1780,11 @@ static void cgroup_kill_sb(struct super_block *sb)
* If @root doesn't have any mounts or children, start killing it.
* This prevents new mounts by disabling percpu_ref_tryget_live().
* cgroup_mount() may wait for @root's release.
+ *
+ * And don't kill the default root.
*/
- if (css_has_online_children(&root->cgrp.self))
+ if (css_has_online_children(&root->cgrp.self) ||
+ root == &cgrp_dfl_root)
cgroup_put(&root->cgrp);
else
percpu_ref_kill(&root->cgrp.self.refcnt);
--
1.8.0.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] cgroup: don't destroy the default root
2014-06-04 8:48 [PATCH v2] cgroup: don't destroy the default root Li Zefan
@ 2014-06-05 1:22 ` Tejun Heo
0 siblings, 0 replies; 2+ messages in thread
From: Tejun Heo @ 2014-06-05 1:22 UTC (permalink / raw)
To: Li Zefan; +Cc: LKML, Cgroups
On Wed, Jun 04, 2014 at 04:48:15PM +0800, Li Zefan wrote:
> The default root is allocated and initialized at boot phase, so we
> shouldn't destroy the default root when it's umounted, otherwise
> it will lead to disaster.
>
> Just try mount and then umount the default root, and the kernel will
> crash immediately.
>
> v2:
> - No need to check for CSS_NO_REF in cgroup_get/put(). (Tejun)
> - Better call cgroup_put() for the default root in kill_sb(). (Tejun)
> - Add a comment.
>
> Signed-off-by: Li Zefan <lizefan@huawei.com>
Applied to cgroup/for-3.16.
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-06-05 1:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-04 8:48 [PATCH v2] cgroup: don't destroy the default root Li Zefan
2014-06-05 1:22 ` Tejun Heo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).