Commit 0e7d91e4 authored by Tycho Andersen's avatar Tycho Andersen Committed by Pavel Emelyanov

cgroup: only collect cgsets once

Instead of doing all the work in collect_cgroup() to figure out whether or
not we've collected this cgroup already, let's only call it if we created a
new cgset in the first place.
Signed-off-by: 's avatarTycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent c0be940b
...@@ -172,13 +172,15 @@ static bool cg_set_compare(struct cg_set *set, struct list_head *ctls, int what) ...@@ -172,13 +172,15 @@ static bool cg_set_compare(struct cg_set *set, struct list_head *ctls, int what)
} }
} }
static struct cg_set *get_cg_set(struct list_head *ctls, unsigned int n_ctls) static struct cg_set *get_cg_set(struct list_head *ctls, unsigned int n_ctls, bool *existed)
{ {
struct cg_set *cs; struct cg_set *cs;
*existed = false;
list_for_each_entry(cs, &cg_sets, l) list_for_each_entry(cs, &cg_sets, l)
if (cg_set_compare(cs, ctls, CGCMP_MATCH)) { if (cg_set_compare(cs, ctls, CGCMP_MATCH)) {
pr_debug(" `- Existing css %d found\n", cs->id); pr_debug(" `- Existing css %d found\n", cs->id);
*existed = true;
put_ctls(ctls); put_ctls(ctls);
return cs; return cs;
} }
...@@ -675,6 +677,7 @@ int dump_task_cgroup(struct pstree_item *item, u32 *cg_id, struct parasite_dump_ ...@@ -675,6 +677,7 @@ int dump_task_cgroup(struct pstree_item *item, u32 *cg_id, struct parasite_dump_
LIST_HEAD(ctls); LIST_HEAD(ctls);
unsigned int n_ctls = 0; unsigned int n_ctls = 0;
struct cg_set *cs; struct cg_set *cs;
bool existed = false;
if (item) if (item)
pid = item->pid.real; pid = item->pid.real;
...@@ -685,7 +688,7 @@ int dump_task_cgroup(struct pstree_item *item, u32 *cg_id, struct parasite_dump_ ...@@ -685,7 +688,7 @@ int dump_task_cgroup(struct pstree_item *item, u32 *cg_id, struct parasite_dump_
if (parse_task_cgroup(pid, args, &ctls, &n_ctls)) if (parse_task_cgroup(pid, args, &ctls, &n_ctls))
return -1; return -1;
cs = get_cg_set(&ctls, n_ctls); cs = get_cg_set(&ctls, n_ctls, &existed);
if (!cs) if (!cs)
return -1; return -1;
...@@ -705,7 +708,7 @@ int dump_task_cgroup(struct pstree_item *item, u32 *cg_id, struct parasite_dump_ ...@@ -705,7 +708,7 @@ int dump_task_cgroup(struct pstree_item *item, u32 *cg_id, struct parasite_dump_
* The on-stack ctls is moved into cs inside * The on-stack ctls is moved into cs inside
* the get_cg_set routine. * the get_cg_set routine.
*/ */
if (cs != criu_cgset && collect_cgroups(&cs->ctls)) if (cs != criu_cgset && !existed && collect_cgroups(&cs->ctls))
return -1; return -1;
} }
......
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