[CRIU] [RFC 2/2] mem: Start using pagemap cache

Pavel Emelyanov xemul at parallels.com
Thu Feb 13 03:36:12 PST 2014


> @@ -105,29 +106,29 @@ static inline bool page_in_parent(u64 pme)
>   * the memory contents is present in the pagent image set.
>   */
>  
> -static int generate_iovs(struct vma_area *vma, int pagemap,
> -			 struct page_pipe *pp, u64 *map, u64 *off)
> +static int generate_iovs(pmc_t *pmc, struct vma_area *vma,
> +			 unsigned long *last_vaddr,
> +			 struct page_pipe *pp)
>  {
> -	unsigned long pfn, nr_to_scan;
> +	unsigned long vaddr = *last_vaddr;
> +	unsigned long nr_to_scan;
>  	unsigned long pages[2] = {};
> -	u64 from, len;
> +	u64 pme;
>  
> -	nr_to_scan = (vma_area_len(vma) - *off) / PAGE_SIZE;
> -	from = (vma->e->start + *off) / PAGE_SIZE * sizeof(*map);
> -	len = nr_to_scan * sizeof(*map);
> -	if (pread(pagemap, map, len, from) != len) {
> -		pr_perror("Can't read pagemap file");
> -		return -1;
> -	}
> +	nr_to_scan = PAGEMAP_PFN(vma->e->end - vaddr);
>  
> -	for (pfn = 0; pfn < nr_to_scan; pfn++) {
> -		unsigned long vaddr;
> +	for (; vaddr < vma->e->end; vaddr += PAGE_SIZE) {

If you want to rename variables (with their meanings) send separate patch with it.

>  		int ret;
>  
> -		if (!should_dump_page(vma->e, map[pfn]))
> -			continue;
> +		pme = pmc_get_pme(pmc, vaddr);
> +		if (pme == PAGEMAP_PME_ERR) {
> +			pr_err("Failed obtain PME for %p\n", (void *)vaddr);
> +			*last_vaddr = vaddr;
> +			return -1;
> +		}
>  
> -		vaddr = vma->e->start + *off + pfn * PAGE_SIZE;
> +		if (!should_dump_page(vma->e, pme))
> +			continue;
>  
>  		/*
>  		 * If we're doing incremental dump (parent images


More information about the CRIU mailing list