From: "Stephen C. Tweedie" <sct@dcs.ed.ac.uk>
To: "Eric W. Biederman" <ebiederm+eric@npwt.net>
Cc: "Benjamin C.R. LaHaise" <blah@kvack.org>, linux-mm@kvack.org
Subject: Re: Fixing private mappings
Date: Fri, 24 Apr 1998 21:37:45 +0100 [thread overview]
Message-ID: <199804242037.VAA01182@dax.dcs.ed.ac.uk> (raw)
In-Reply-To: <m1g1j4nqll.fsf@flinx.npwt.net>
Hi,
On 23 Apr 1998 17:03:02 -0500, ebiederm+eric@npwt.net (Eric
W. Biederman) said:
>>> Definition of Private Mappings:
>>> A private mapping is a copy-on-write mapping of a file.
>>>
>>> That is if the file is written to after the mapping is established,
>>> the contents of the mapping will always remain what the contents of
>>> the file was at the time of the private mapping.
BL> Note: 'the initial write reference will create a private copy' -- not
BL> the act of reading or mapping.
> Right. That is probably the only reasonable way to implement it.
Indeed.
> I stated it as I did so what happens if another process writes to the
> file is clear. Another process writing to the file will be the
> `initial write reference'.
No --- in the context of a MAP_PRIVATE mapping, only in-memory writes to
the privately mapped virtual address space count as write references.
> So logically MAP_PRIVATE gives you a snapshot of the contents of a
> file. Not that it actually takes that snapshot...
No, it shouldn't --- it maps the file into the process address space,
and all updates to the file are reflected in the process's virtual
memory copy. Only if the process tries to write to the file is the COW
activated.
> Possibly I'm failing to see the difference in the definitions?
Yep. MAP_PRIVATE mappings preserve the correspondance over writes to
the file by any mechanism other than modifying the mapping itself.
Note that the semantics are relaxed a bit if we have non-page-aligned
private maps, in that the correspondance between the mapped image and
the file contents is no longer always preserved if the file is updated.
> The problem is update_vm_cache only looks currently for the primary
> inode page. The one at (offset%PAGE_SIZE)==0. So the other page at
> offset%PAGE_SIZE==1k is not updated.
Yep, but we are not required to support non-page-aligned maps at all, so
hacking it for special read-only cases is no big deal. Doing a search
for all overlapping mapped pages would be far too slow.
--Stephen
next prev parent reply other threads:[~1998-04-24 20:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-04-23 5:06 Eric W. Biederman
1998-04-23 8:28 ` Rik van Riel
1998-04-23 15:12 ` Benjamin C.R. LaHaise
1998-04-23 22:03 ` Eric W. Biederman
1998-04-24 20:37 ` Stephen C. Tweedie [this message]
1998-04-25 5:30 ` Eric W. Biederman
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=199804242037.VAA01182@dax.dcs.ed.ac.uk \
--to=sct@dcs.ed.ac.uk \
--cc=blah@kvack.org \
--cc=ebiederm+eric@npwt.net \
--cc=linux-mm@kvack.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox