Re: mmap confusion

Michał Nazarewicz <[email protected]>
Newsgroups gmane.linux.newbie,gmane.linux.kernel.kernelnewbies
Organization Samsung Electronics
Message-ID <op.vjbql71x7p4s8u@pikus>
On Mon, 20 Sep 2010 07:33:05 +0200, Rajat Jain <[email protected]> wrote:

> 1) If the backing file is /dev/mem or a device file, then at the time of mmap(),
> the page table entries / TLB entries are set up such that the virtual address in
> the user space, maps to the actual physical address desired. And the thus job
> is done. This case is clear.

Page table entries don't need to be set immediately but essentially that is the
case.

> 2) The other case is that when the file is actually a datafile present in a file
> system lets say on a SATA disk. Now, for each load / store in the application,
> some driver code needs to trigger that will program the SATA controller registers
> and do n number of thinks to initiate the diska read / write transaction. How is
> this achieved? Because application is not making any System calls. Its just having
> load / store instructions.

When a "normal" file is mapped no page entries are set.  As an effect, when user
space refers to the mapped area a page fault is triggered.  This is handled by
kernel which reads a page from the disk and adds a proper page table entry.

On writes, such a page is marked as dirty (either CPU supports that directly,
or kernel simulates it by setting page read-only so that on write an page fault
is generated again).  When process terminates all dirty pages are written back to
disk.

-- 
Best regards,                                        _     _
| Humble Liege of Serenely Enlightened Majesty of  o' \,=./ `o
| Computer Science,  Michał "mina86" Nazarewicz       (o o)
+----[mina86*mina86.com]---[mina86*jabber.org]----ooO--(_)--Ooo--
--
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.