From: Amol Kumar Lad <amolk@ishoni.com>
To: linux-mm@kvack.org
Subject: mincore_vma function
Date: 18 Nov 2002 13:30:29 -0500 [thread overview]
Message-ID: <1037644230.10326.57.camel@amol.in.ishoni.com> (raw)
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/
reply other threads:[~2002-11-18 8:04 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1037644230.10326.57.camel@amol.in.ishoni.com \
--to=amolk@ishoni.com \
--cc=linux-mm@kvack.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox