Commit 97f7d179 authored by Pavel Emelyanov's avatar Pavel Emelyanov

cg: Don't walk cgroup tree when it's not required

We have two bugs actually.

First, the check for 'item == root_item' in dump_task_cgroup fires
twice: first when we rite inventory (item == NULL as argument and
root_item == NULL because we haven't yet collected tasks) and the
2nd time when we dump the root task itself.

The 2nd issue sits in dump_cgroups() -- if root_cgset == criu_cgset
we don't write cgroups information at all (checking that we don't
have them with list_is_singular() inside that if). That said, we
don't need to read the cgroups tree if we're not going to dump it.

This patch fixes both.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
Acked-by: 's avatarAndrew Vagin <avagin@parallels.com>
Acked-by: 's avatarTycho Andersen <tycho.andersen@canonical.com>
parent 9b6c41f2
......@@ -439,9 +439,6 @@ int dump_task_cgroup(struct pstree_item *item, u32 *cg_id)
if (parse_task_cgroup(pid, &ctls, &n_ctls))
return -1;
if (item == root_item && collect_cgroups(&ctls) < 0)
return -1;
cs = get_cg_set(&ctls, n_ctls);
if (!cs)
return -1;
......@@ -454,6 +451,13 @@ int dump_task_cgroup(struct pstree_item *item, u32 *cg_id)
BUG_ON(root_cgset);
root_cgset = cs;
pr_info("Set %d is root one\n", cs->id);
/*
* The on-stack ctls is moved into cs inside
* the get_cg_set routine.
*/
if (cs != criu_cgset && collect_cgroups(&cs->ctls))
return -1;
}
*cg_id = cs->id;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment