Commit 93f3fa34 authored by Mike Rapoport's avatar Mike Rapoport Committed by Andrei Vagin

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: 's avatarMike Rapoport <rppt@linux.vnet.ibm.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent 2ad16d4c
...@@ -97,6 +97,7 @@ struct lazy_pages_info { ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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;
......
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