mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-31 06:15:24 +00:00
restore: Restore as many pages at once as possible
When the VMA being restored is not COW-ed we read pages from images one-by-one which results in suboptimal pages.img access. Fix this by reading as many pages from iamge at once as possible withing the active pagemap and VMA. Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
28
cr-restore.c
28
cr-restore.c
@@ -468,8 +468,8 @@ static int restore_priv_vma_content(void)
|
|||||||
ret = pr.read_pages(&pr, va, 1, buf);
|
ret = pr.read_pages(&pr, va, 1, buf);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto err_read;
|
goto err_read;
|
||||||
va += PAGE_SIZE;
|
|
||||||
|
|
||||||
|
va += PAGE_SIZE;
|
||||||
nr_compared++;
|
nr_compared++;
|
||||||
|
|
||||||
if (memcmp(p, buf, PAGE_SIZE) == 0) {
|
if (memcmp(p, buf, PAGE_SIZE) == 0) {
|
||||||
@@ -477,15 +477,35 @@ static int restore_priv_vma_content(void)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nr_restored++;
|
||||||
memcpy(p, buf, PAGE_SIZE);
|
memcpy(p, buf, PAGE_SIZE);
|
||||||
} else {
|
} else {
|
||||||
ret = pr.read_pages(&pr, va, 1, p);
|
int nr, j;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Try to read as many pages as possible at once.
|
||||||
|
*
|
||||||
|
* Within the current pagemap we still have
|
||||||
|
* nr_pages - i pages (not all, as we might have
|
||||||
|
* switched VMA above), within the current VMA
|
||||||
|
* we have at most (vma->end - current_addr) bytes.
|
||||||
|
*/
|
||||||
|
|
||||||
|
nr = min(nr_pages - i, (vma->e->end - va) / PAGE_SIZE);
|
||||||
|
|
||||||
|
ret = pr.read_pages(&pr, va, nr, p);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto err_read;
|
goto err_read;
|
||||||
va += PAGE_SIZE;
|
|
||||||
|
va += nr * PAGE_SIZE;
|
||||||
|
nr_restored += nr;
|
||||||
|
i += nr - 1;
|
||||||
|
|
||||||
|
/* FIXME -- optimize */
|
||||||
|
for (j = 1; j < nr; j++)
|
||||||
|
set_bit(off + j, vma->page_bitmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
nr_restored++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pr.put_pagemap)
|
if (pr.put_pagemap)
|
||||||
|
Reference in New Issue
Block a user