mirror of
https://github.com/checkpoint-restore/criu
synced 2025-09-03 15:55:53 +00:00
lazy-pages: cache buffer size in the lazy_pages_info
Instead of recalculating required for lazy_pages_info->buf when copying IOVs at fork() time, keep the size of the buffer in the lazy_pages_info struct. Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com> Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
committed by
Andrei Vagin
parent
9fe912f974
commit
d4d09942de
11
criu/uffd.c
11
criu/uffd.c
@@ -97,6 +97,7 @@ struct lazy_pages_info {
|
|||||||
|
|
||||||
struct list_head l;
|
struct list_head l;
|
||||||
|
|
||||||
|
unsigned long buf_size;
|
||||||
void *buf;
|
void *buf;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -445,7 +446,6 @@ static void merge_iov_lists(struct list_head *src, struct list_head *dst)
|
|||||||
static int copy_iovs(struct lazy_pages_info *src, struct lazy_pages_info *dst)
|
static int copy_iovs(struct lazy_pages_info *src, struct lazy_pages_info *dst)
|
||||||
{
|
{
|
||||||
struct lazy_iov *iov, *new;
|
struct lazy_iov *iov, *new;
|
||||||
int max_iov_len = 0;
|
|
||||||
|
|
||||||
list_for_each_entry(iov, &src->iovs, l) {
|
list_for_each_entry(iov, &src->iovs, l) {
|
||||||
new = xzalloc(sizeof(*new));
|
new = xzalloc(sizeof(*new));
|
||||||
@@ -457,12 +457,10 @@ static int copy_iovs(struct lazy_pages_info *src, struct lazy_pages_info *dst)
|
|||||||
new->end = iov->end;
|
new->end = iov->end;
|
||||||
|
|
||||||
list_add_tail(&new->l, &dst->iovs);
|
list_add_tail(&new->l, &dst->iovs);
|
||||||
|
|
||||||
if (new->end - new->start > max_iov_len)
|
|
||||||
max_iov_len = new->end - new->start;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (posix_memalign(&dst->buf, PAGE_SIZE, max_iov_len))
|
dst->buf_size = src->buf_size;
|
||||||
|
if (posix_memalign(&dst->buf, PAGE_SIZE, dst->buf_size))
|
||||||
goto free_iovs;
|
goto free_iovs;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -653,7 +651,8 @@ static int collect_iovs(struct lazy_pages_info *lpi)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (posix_memalign(&lpi->buf, PAGE_SIZE, max_iov_len))
|
lpi->buf_size = max_iov_len;
|
||||||
|
if (posix_memalign(&lpi->buf, PAGE_SIZE, lpi->buf_size))
|
||||||
goto free_iovs;
|
goto free_iovs;
|
||||||
|
|
||||||
ret = nr_pages;
|
ret = nr_pages;
|
||||||
|
Reference in New Issue
Block a user