lkml.org 
[lkml]   [2008]   [Sep]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC v4][PATCH 5/9] Memory managemnet (restore)


Dave Hansen wrote:
> On Tue, 2008-09-09 at 03:42 -0400, Oren Laadan wrote:
>> +/**
>> + * cr_vma_read_pages_vaddrs - read addresses of pages to page-array chain
>> + * @ctx - restart context
>> + * @npages - number of pages
>> + */
>> +static int cr_vma_read_pages_vaddrs(struct cr_ctx *ctx, int npages)
>> +{
>> + struct cr_pgarr *pgarr;
>> + int nr, ret;
>> +
>> + while (npages) {
>> + pgarr = cr_pgarr_prep(ctx);
>> + if (!pgarr)
>> + return -ENOMEM;
>> + nr = min(npages, (int) pgarr->nr_free);
>> + ret = cr_kread(ctx, pgarr->vaddrs, nr * sizeof(unsigned long));
>> + if (ret < 0)
>> + return ret;
>> + pgarr->nr_free -= nr;
>> + pgarr->nr_used += nr;
>> + npages -= nr;
>> + }
>> + return 0;
>> +}
>
> cr_pgarr_prep() can return a partially full pgarr, right? Won't the
> cr_kread() always start at the beginning of the pgarr->vaddrs[] array?
> Seems to me like it will clobber things from the last call.

Note that 'nr' is either equal to ->nr_free - in which case we consume
the entire 'pgarr' vaddr array such that the next call to cr_pgarr_prep()
will get a fresh one, or is smaller than ->nr_free - in which case that
is the last iteration of the loop anyhow, so it won't be clobbered.

Also, after we return - our caller, cr_vma_read_pages(), resets the state
of the page-array chain by calling cr_pgarr_reset().

Oren.


\
 
 \ /
  Last update: 2008-09-10 21:53    [W:0.068 / U:0.300 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site