After adding container support for cgroup,there will be many roots. Add a helper function cgroup_in_root,only operate the cgroup when it's in the root. Signed-off-by: Gao feng <gaofeng@xxxxxxxxxxxxxx> --- kernel/cgroup.c | 17 +++++++++++++++-- 1 files changed, 15 insertions(+), 2 deletions(-) diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 2e14c8f..0195db1 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c @@ -850,6 +850,14 @@ static struct backing_dev_info cgroup_backing_dev_info = { static int alloc_css_id(struct cgroup_subsys *ss, struct cgroup *parent, struct cgroup *child); +static inline bool cgroup_in_root(struct cgroup *cgrp, + struct cgroupfs_root *root) +{ + if (root == cgrp->root) + return true; + return false; +} + /* * Find out the top root by subsys_mask. */ @@ -2047,7 +2055,8 @@ int cgroup_attach_task_all(struct task_struct *from, struct task_struct *tsk) cgroup_lock(); for_each_active_root(root) { struct cgroup *from_cg = task_cgroup_from_root(from, root); - + if (!cgroup_in_root(from_cg, root)) + continue; retval = cgroup_attach_task(from_cg, tsk); if (retval) break; @@ -4786,6 +4795,10 @@ static int proc_cgroup_show(struct seq_file *m, void *v) struct cgroup *cgrp; int count = 0; + cgrp = task_cgroup_from_root(tsk, root); + if (!cgroup_in_root(cgrp, root)) + continue; + seq_printf(m, "%d:", root->hierarchy_id); for_each_subsys(root, ss) seq_printf(m, "%s%s", count++ ? "," : "", ss->name); @@ -4793,7 +4806,7 @@ static int proc_cgroup_show(struct seq_file *m, void *v) seq_printf(m, "%sname=%s", count ? "," : "", root->name); seq_putc(m, ':'); - cgrp = task_cgroup_from_root(tsk, root); + retval = cgroup_path(cgrp, buf, PAGE_SIZE); if (retval < 0) goto out_unlock; -- 1.7.7.6 _______________________________________________ Containers mailing list Containers@xxxxxxxxxxxxxxxxxxxxxxxxxx https://lists.linuxfoundation.org/mailman/listinfo/containers