Commit 9f814087 authored by Tycho Andersen's avatar Tycho Andersen Committed by Pavel Emelyanov

cgroup: only inspect the root task for cgns prefixes

Because we don't support nested cgroup namespaces, we can just grab the
cgns prefixes from the root cgset's prefix list. This means we only have to
query one task for its cgroup file, instead of potentially each of them.
Signed-off-by: 's avatarTycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 16d3fdef
......@@ -701,9 +701,31 @@ int dump_task_cgroup(struct pstree_item *item, u32 *cg_id, struct parasite_dump_
BUG_ON(root_cgset);
root_cgset = cs;
pr_info("Set %d is root one\n", cs->id);
} else
} else {
struct cg_ctl *root, *stray;
BUG_ON(!root_cgset);
pr_info("Set %d is a stray\n", cs->id);
/* Copy the cgns prefix from the root cgset for each
* controller. This is ok because we know that there is
* only one cgroup namespace.
*/
list_for_each_entry(root, &root_cgset->ctls, l) {
list_for_each_entry(stray, &cs->ctls, l) {
if (strcmp(root->name, stray->name))
continue;
if (strlen(stray->path) < root->cgns_prefix) {
pr_err("cg %s shorter than path prefix %d?\n", stray->path, root->cgns_prefix);
return -1;
}
stray->cgns_prefix = root->cgns_prefix;
}
}
}
/*
* The on-stack ctls is moved into cs inside
* the get_cg_set routine.
......
......@@ -728,14 +728,11 @@ static int dump_task_core_all(struct parasite_ctl *ctl,
if (ret)
goto err;
/* If this is the root task and it has a cgroup ns id, it could be in
* a cgroup namespace and we should try to figure out the prefix. Or,
* if the task is not the parent task and its cgroup namespace differs
* from its parent's, this is a nested cgns and we should compute the
* prefix.
/* For now, we only need to dump the root task's cgroup ns, because we
* know all the tasks are in the same cgroup namespace because we don't
* allow nesting.
*/
if (item->ids->has_cgroup_ns_id && (!item->parent ||
(item->ids->cgroup_ns_id != item->parent->ids->cgroup_ns_id))) {
if (item->ids->has_cgroup_ns_id && !item->parent) {
info = &cgroup_args;
ret = parasite_dump_cgroup(ctl, &cgroup_args);
if (ret)
......
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