Subject: Re: new mremap(2): relax alignment restrictions?
To: None <tech-kern@netbsd.org>
From: Joerg Sonnenberger <joerg@britannica.bec.de>
List: tech-kern
Date: 07/30/2007 17:31:43
On Mon, Jul 30, 2007 at 10:18:19AM -0500, Eric Haszlakiewicz wrote:
> On Mon, Jul 30, 2007 at 11:14:33AM +0200, Joerg Sonnenberger wrote:
> > On Tue, Jul 24, 2007 at 05:15:31PM -0500, Eric Haszlakiewicz wrote:
> > >  if you map a 10 byte file (for example), the mmap man page says that
> > > the mapped region may be extended up to the page size.
> > >   I suppose there's a bit of a performance hit with zeroing out the page
> > > every time, but it seems like a necessary thing to do.  A couple other
> > > OSes I've tried it on do so.
> > 
> > This discussion is lame. There are four possible approaches to this
> > problem:
> > (1) Discontinue UCB. Inacceptible as it introduces far more issues than
> > it is worth.
> > (2) Zero the page at random times (e.g. scheduling). Doesn't fix the
> > issue, just makes the window smaller.
> > (3) Trap on write. Horrible performance, MP issues.
> > (4) Disallow mmap for write on not page-sized files. Standard compliance
> > issues.
> 
> 5) Zero the page at mmap time.  Fixes all cases except two concurrently
> running processes reading and writing to the area beyond the end of the
> file.  Some performance drop, but less than the other options.

This is pretty much (2).

Joerg