All of lore.kernel.org
 help / color / mirror / Atom feed
From: Robin Holt <holt@sgi.com>
To: Lutz Vieweg <lkv@isg.de>
Cc: linux-kernel@vger.kernel.org
Subject: Re: How to find out which pages were copied-on-write?
Date: Fri, 9 Jul 2004 06:31:25 -0500	[thread overview]
Message-ID: <20040709113125.GA8897@lnx-holt.americas.sgi.com> (raw)
In-Reply-To: <40EACC0C.6060606@isg.de>

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

  reply	other threads:[~2004-07-09 11:31 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-06 15:58 How to find out which pages were copied-on-write? Lutz Vieweg
2004-07-09 11:31 ` Robin Holt [this message]
2004-07-09 20:42   ` Lutz Vieweg
2004-07-10  8:11     ` Michael Clark
2004-07-12 17:21       ` Lutz Vieweg
2004-07-13  4:16         ` Michael Clark
2004-07-13 13:04           ` Lutz Vieweg
2004-07-13 15:02             ` Michael Clark
2004-07-13 15:39               ` Lutz Vieweg
2004-07-14  0:25                 ` Michael Clark

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040709113125.GA8897@lnx-holt.americas.sgi.com \
    --to=holt@sgi.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkv@isg.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.