Commit f7d0263c authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

restore: add fast path to find a parent pstree item

Taking into account the way the dump saves pstrees in the image.

If pstree.img isn't edited, a slow path should not be executed at all.
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent cf63c1d9
...@@ -115,9 +115,21 @@ static int prepare_pstree(void) ...@@ -115,9 +115,21 @@ static int prepare_pstree(void)
pi->parent = NULL; pi->parent = NULL;
INIT_LIST_HEAD(&pi->list); INIT_LIST_HEAD(&pi->list);
} else { } else {
for_each_pstree_item(parent) /*
* Fast path -- if the pstree image is not edited, the
* parent of any item should have already being restored
* and sit among the last item's ancestors.
*/
while (parent) {
if (parent->pid == e.ppid) if (parent->pid == e.ppid)
break; break;
parent = parent->parent;
}
if (parent == NULL)
for_each_pstree_item(parent)
if (parent->pid == e.ppid)
break;
if (parent == NULL) { if (parent == NULL) {
pr_err("Can't find a parent for %d", pi->pid); pr_err("Can't find a parent for %d", pi->pid);
...@@ -129,6 +141,8 @@ static int prepare_pstree(void) ...@@ -129,6 +141,8 @@ static int prepare_pstree(void)
list_add(&pi->list, &parent->children); list_add(&pi->list, &parent->children);
} }
parent = pi;
pi->nr_threads = e.nr_threads; pi->nr_threads = e.nr_threads;
pi->threads = xmalloc(e.nr_threads * sizeof(u32)); pi->threads = xmalloc(e.nr_threads * sizeof(u32));
if (!pi->threads) if (!pi->threads)
......
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