* mincore_vma function
@ 2002-11-18 18:30 Amol Kumar Lad
0 siblings, 0 replies; only message in thread
From: Amol Kumar Lad @ 2002-11-18 18:30 UTC (permalink / raw)
To: linux-mm
Hi,
I'm bit confused while reading this function
static long mincore_vma(struct vm_area_struct * vma,
unsigned long start, unsigned long end, unsigned char * vec)
{
long error, i, remaining;
unsigned char * tmp;
error = -ENOMEM;
if (!vma->vm_file)
return error;
start = ((start - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff;
if (end > vma->vm_end)
end = vma->vm_end;
end = ((end - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff;
error = -EAGAIN;
tmp = (unsigned char *) __get_free_page(GFP_KERNEL);
if (!tmp)
return error;
/* (end - start) is # of pages, and also # of bytes in "vec */
remaining = (end - start),
error = 0;
for (i = 0; remaining > 0; remaining -= PAGE_SIZE, i++) {
int j = 0;
long thispiece = (remaining < PAGE_SIZE) ?
remaining : PAGE_SIZE;
>>>> Why this check ? Is it possible the remaining is not a multiple of
page (remaining = end - start)
while (j < thispiece)
tmp[j++] = mincore_page(vma, start++);
>>>> why this loop ?? Don't we only need to call mincore_page _once_
with second arg start += PAGE_SIZE;
if (copy_to_user(vec + PAGE_SIZE * i, tmp, thispiece)) {
error = -EFAULT;
break;
}
>>>> Again, accroding to man page of mincore, each byte of vec tells
whether page is resident or not... What is above copy_to_user doing
}
free_page((unsigned long) tmp);
return error;
}
I am using 2.4.57-mm2
-- Amol
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2002-11-18 8:04 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-18 18:30 mincore_vma function Amol Kumar Lad
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox