<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Jul 25, 2013 at 5:18 PM, <span dir="ltr"><<a href="mailto:Valdis.Kletnieks@vt.edu" target="_blank">Valdis.Kletnieks@vt.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On Thu, 25 Jul 2013 16:57:44 -0700, kernel neophyte said:<br>
<br>
> I am sorry, its still not clear to me. All I am asking is I want to know<br>
</div>> and understand how mmap works, given an address *X*, how does the Linux<br>
> kernel figure out that *X* is an mmaped page?<br>
<br>
Before you ask *how* it does it, first figure out if it does it *at all*.<br>
<br>
The reason you can't figure out how the swami is levitating is because<br>
they aren't actually levitating at all.<br></blockquote><div><br></div><div>:-) Good one! </div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im"><br>
> Is there a special flag in<br>
> the page table entry?<br>
<br>
</div>No, because no flag is needed.<br>
<div class="im"><br>
> Does the access generate a page fault ?<br>
<br>
</div>Maybe, maybe not. If the page is resident in memory there's no page fault.<br>
And if it's not resident, it gets paged in from wherever the backing page<br>
happens to be.<br>
<div class="im"><br>
> If so, how<br>
> does the handler find out it is an mmaped address?<br>
<br>
</div>The handler doesn't *care* if it's mmaped. All it has to know is (1) this<br>
page isn't in memory, (2) it needs to be in memory, and (3) so please schedule<br>
the I/O to read it from block NNNN of device XXYY just like any *other*<br>
page being read in because of a page fault.<br>
<br></blockquote><div><br></div><div>Thanks, I get it now. </div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
The *only* thing "magical" about an mmap'ed page is that the pointer to where<br>
to read/write it might (sometimes) point at someplace that's not a swap space. </blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Though for some uses of mmap(), it *does* point at swap space (for instance,<br>
the anonymous pages created by mmap() as used from malloc() in glibc).<br>
<br>
</blockquote></div>Thanks I get it now. </div><div class="gmail_extra"><br></div><div class="gmail_extra">-Neo</div></div>