<br><br><div class="gmail_quote">On Wed, Sep 21, 2011 at 2:24 AM, Jeff Haran <span dir="ltr"><<a href="mailto:jharan@bytemobile.com">jharan@bytemobile.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
> -----Original Message-----<br>
> From: <a href="mailto:kernelnewbies-bounces@kernelnewbies.org">kernelnewbies-bounces@kernelnewbies.org</a> [mailto:<a href="mailto:kernelnewbies-">kernelnewbies-</a><br>
> <a href="mailto:bounces@kernelnewbies.org">bounces@kernelnewbies.org</a>] On Behalf Of Sri Ram Vemulpali<br>
> Sent: Tuesday, September 20, 2011 11:24 AM<br>
> To: kernelnewbies<br>
> Subject: question on memory mapping one page at a time<br>
<div class="im">><br>
> Hi all,<br>
><br>
> can anyone please explain the following code, what it is doing. I want<br>
> the first few statements of the code, as they are calculating page<br>
> frame number. This is little confusing, thanks in advance.<br>
><br>
> struct page *simple_vma_nopage(struct vm_area_struct *vma,<br>
> unsigned long address, int *type)<br>
> {<br>
> struct page *pageptr;<br>
> unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;<br>
> unsigned long physaddr = address - vma->vm_start + offset;<br>
> unsigned long pageframe = physaddr >> PAGE_SHIFT;<br>
> if (!pfn_valid(pageframe))<br>
> return NOPAGE_SIGBUS;<br>
> pageptr = pfn_to_page(pageframe);<br>
> get_page(pageptr);<br>
> if (type)<br>
> *type = VM_FAULT_MINOR;<br>
> return pageptr;<br>
> }<br>
><br>
> --<br>
> Regards,<br>
> Sri.<br>
<br>
</div>Do a search on "Understanding the Linux Virtual Memory Manager" by Mel<br>
Gorman. The PDF is out there for free or you can buy the hardcopy.<br>
<br>
I think you will find the above code clearer after you've read the<br>
above.<br>
<font color="#888888"><br>
Jeff Haran<br>
</font><div><div></div><div class="h5"><br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
Kernelnewbies mailing list<br>
<a href="mailto:Kernelnewbies@kernelnewbies.org">Kernelnewbies@kernelnewbies.org</a><br>
<a href="http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" target="_blank">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br>
</div></div></blockquote></div><br>Also you can go through the second chapter of understanding linux kernel.<br><br>Regards,<br>Rohan Puri<br>