mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-30 22:05:36 +00:00
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: Andrey Vagin <avagin@openvz.org> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
committed by
Pavel Emelyanov
parent
cf63c1d9e8
commit
f7d0263c69
16
cr-restore.c
16
cr-restore.c
@@ -115,9 +115,21 @@ static int prepare_pstree(void)
|
||||
pi->parent = NULL;
|
||||
INIT_LIST_HEAD(&pi->list);
|
||||
} 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)
|
||||
break;
|
||||
parent = parent->parent;
|
||||
}
|
||||
|
||||
if (parent == NULL)
|
||||
for_each_pstree_item(parent)
|
||||
if (parent->pid == e.ppid)
|
||||
break;
|
||||
|
||||
if (parent == NULL) {
|
||||
pr_err("Can't find a parent for %d", pi->pid);
|
||||
@@ -129,6 +141,8 @@ static int prepare_pstree(void)
|
||||
list_add(&pi->list, &parent->children);
|
||||
}
|
||||
|
||||
parent = pi;
|
||||
|
||||
pi->nr_threads = e.nr_threads;
|
||||
pi->threads = xmalloc(e.nr_threads * sizeof(u32));
|
||||
if (!pi->threads)
|
||||
|
Reference in New Issue
Block a user