2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-31 14:25:49 +00:00

lazy-pages: introduce uffd_seek_or_zero_pages

This part of code is responsible for reseting pagemap to proper locatation,
and mapping requested address to zero pfn if needed. The upcoming addtions
to uffd.c will reuse this code.

travis-ci: success for uffd: A new set of improvements
Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
This commit is contained in:
Mike Rapoport
2016-11-15 18:57:25 +02:00
committed by Andrei Vagin
parent 250448559f
commit d4edd9bf56

View File

@@ -569,7 +569,17 @@ static int uffd_zero(struct lazy_pages_info *lpi, __u64 address, int nr_pages)
return 0;
}
static int uffd_handle_pages(struct lazy_pages_info *lpi, __u64 address, int nr)
/*
* Seek for the requested address in the pagemap. If it is found, the
* subsequent call to pr->page_read will bring us the data. If the
* address is not found in the pagemap, but no error occured, the
* address should be mapped to zero pfn.
*
* Returns 0 for zero pages, 1 for "real" pages and negative value on
* error
*/
static int uffd_seek_or_zero_pages(struct lazy_pages_info *lpi, __u64 address,
int nr)
{
int ret;
@@ -582,6 +592,17 @@ static int uffd_handle_pages(struct lazy_pages_info *lpi, __u64 address, int nr)
if (pagemap_zero(lpi->pr.pe))
return uffd_zero(lpi, address, nr);
return 1;
}
static int uffd_handle_pages(struct lazy_pages_info *lpi, __u64 address, int nr)
{
int ret;
ret = uffd_seek_or_zero_pages(lpi, address, nr);
if (ret <= 0)
return ret;
ret = lpi->pr.read_pages(&lpi->pr, address, nr, lpi->buf, 0);
if (ret <= 0) {
pr_err("%d: failed reading pages at %llx\n", lpi->pid, address);