Re: How to find out which pages were copied-on-write?

From: Robin Holt
Date: Fri Jul 09 2004 - 06:32:49 EST


OK, now that I am considering this problem, I am trying to figure out
what problem we are trying to solve.

By reading your email, I gather that you have a single threaded
application which is doing an mmap on a file as a MAP_PRIVATE mapping.
The memory area is then handed to a library which may modify some pages.
You want to decide after the return if you had success and thereby
control the writing of the updated data back to the file. Because of
the size of the file, doing a second mapping and comparing/copying pages
is unreasonable and you would like to only modify the pages that have
actually changed.

If that is not what you are trying to do, please give me a similar
description of _WHAT_ you are trying to do and not the _HOW_ you think
the kernel can make this easier.


On Tue, Jul 06, 2004 at 05:58:04PM +0200, Lutz Vieweg wrote:
> Hi,
>
> in an application that MAP_PRIVATEly mmap()s a file it would
> be quite helpful for me to find out which pages have been
> copied-on-write.
>
> I found that mincore() does a similar thing by reporting which
> pages are currently residing in physical memory, but what
> I want to know is which pages differ from the original file
> image on disk.
>
> Can you recommend a way to do that? (does not need to be
> portable beyond Linux)
>
> Alternatively, it would be sufficient if I could turn
> a private mapping into a shared one (and possibly do an
> msync() afterwards if I need to make sure the changes
> have been written out). Would such a feature need a
> lot of effort to implement?
>
>
> Yet another feature that I could use if it were available:
> A "copy-on-read"-mapping. There, a page would become a private
> copy of a process once _another_ process wrote data to the
> corresponding file location. But I suspect that feature
> could be very hard to implement...

This is a different way of thinking of copy-on-write. I believe you
are thinking of the time when there are two processes sharing the page.
When one process takes the write fault, the page is copied and the by that
process and the other process becomes the exclusive owner of the page.

Thanks,
Robin Holt
-
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/