[RFC v4][PATCH 4/9] Memory management (dump)

Dave Hansen dave at linux.vnet.ibm.com
Wed Sep 10 14:38:58 PDT 2008


On Tue, 2008-09-09 at 03:42 -0400, Oren Laadan wrote:
> array chain
> + */
> +static int cr_vma_scan_pages(struct cr_ctx *ctx, struct vm_area_struct *vma)
> +{
> +       unsigned long addr = vma->vm_start;
> +       unsigned long end = vma->vm_end;
> +       struct cr_pgarr *pgarr;
> +       int nr, total = 0;
> +
> +       while (addr < end) {
> +               pgarr = cr_pgarr_prep(ctx);
> +               if (!pgarr)
> +                       return -ENOMEM;
> +               nr = cr_vma_fill_pgarr(ctx, pgarr, vma, &addr);
> +               if (nr < 0)
> +                       return nr;
> +               pgarr->nr_free -= nr;
> +               pgarr->nr_used += nr;
> +               total += nr;
> +       }
> +
> +       cr_debug("total %d\n", total);
> +       return total;
> +}

This confuses me.  cr_vma_fill_pgarr() if it runs into an error attempts
to free up the pgarr references from the current pgarr that was just
filled.  But, that could only be a portion of a large VMA.  If it can't
free up the entire VMA worth of references (at least), why does it even
try to free a portion?  Why not just return since the upper levels need
to clean up the other portions anyway?

Also, is it really necessary to track the total amount filled in here?
I kinda gums up the code.

-- Dave



More information about the Containers mailing list