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

From: Dave Hansen
Date: Wed Sep 10 2008 - 17:39:17 EST


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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/