Re: how do file-mapped (mmapped) pages become dirty?

From: Richard B. Johnson
Date: Tue Oct 28 2003 - 10:39:17 EST


On Tue, 28 Oct 2003, Amir Hermelin wrote:

> Hi,
> When a process mmaps a file, how does the kernel know the memory has been
> written to (and hence the page is dirty)? Is this done by setting the

This is automatically done by the CPU (no overhead) with Intel
CPUs.

> protected flag, and when the memory is first written to it's set to dirty?
> What function is responsible for this setting? And when will the page be
> written back to disk (i.e. where's the flusher located)?
>

If you start to run low on memory, the disk buffer(s) may be flushed
to the hardware. Otherwise, you need an explicit fsync() or a close().

Any reads by others will always show updated changes. You don't
need to do anything special.

Cheers,
Dick Johnson
Penguin : Linux version 2.4.22 on an i686 machine (797.90 BogoMips).
Note 96.31% of all statistics are fiction.


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/