Subject: Re: Partial fix for the NetBSD VM problem
To: None <firstname.lastname@example.org, tech-kern@NetBSD.ORG>
From: Mike Hibler <email@example.com>
Date: 03/03/1996 15:19:27
> Date: Sat, 2 Mar 1996 11:35:09 -0500
> From: Greg Hudson <ghudson@MIT.EDU>
> To: tech-kern@NetBSD.ORG
> Subject: Partial fix for the NetBSD VM problem
> Included below is a patch to fix what I consider to be the important
> parts of the NetBSD VM problem:
> * msync() doesn't sync all pages of a MAP_PRIVATE map.
> (Thanks to Mike Hibler for identifying the fix.)
A couple of notes. A shadow object has an offset into the object that
it shadows (i.e., offset 0 in shadow object, is not always offset 0 in
shadowed object) so you need to adjust the offset as you traverse the chain.
May have to watch out for differences in size as well.
As implemented you will be potentially cleaning/flushing more than you have
to. If a page exists in a shadow object, it may also exist in every other
object further along the chain. You only need to clean/flush it from the
first object. For example, if every page in an mmap'ed region has been
modified, every page will be in the top level object and there is no need
to go any further. I'm not sure what the most efficient way to implement
this is though...
> I don't consider either of the above two problems serious, since they
> don't affect vi (as far as I can tell, vi should be using MAP_COPY
> anyway) and they don't affect running executables. Fixing the first
> problem could be done by adding sufficient hair to the buffer cache to
> invalidate VM pages when files change; fixing the second problem
> requires a unified VM and buffer cache. I believe POSIX.1b allows one
> or both of the above behaviors, but I haven't checked.
You shouldn't use MAP_COPY, it doesn't work correctly for split accesses.
If you have an untouched page mmap'ed with MAP_COPY, and someone modifies
it through the buffer cache, you will see the changed version when you do
touch the page. If MAP_COPY worked correctly, you would see the original
version. If you want true copy semantics, use read.