Subject: Re: new mremap(2): relax alignment restrictions?
To: Eric Haszlakiewicz <erh@nimenees.com>
From: Antti Kantee <pooka@cs.hut.fi>
List: tech-kern
Date: 07/25/2007 01:25:42
On Tue Jul 24 2007 at 17:15:31 -0500, Eric Haszlakiewicz wrote:
> hmmm... beyond a bit bogus, the behaviour of our mmap just seems wrong:
>  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.  That seems
> reasonable to me, but the man page also says any bytes beyond the end
> of the mapped object will be zero filled.  This isn't always the case.
> When I try it I get data that was in memory from a previous run of my
> program.  (char *p=mmap(), assert(p[11] == 0), p[11] = 'X' fails on the
> second run)
>   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.

Sounds like the semantics lie down a slippery slope.  What happens e.g.
if you shared map the same file twice, use different sizes and offsets
and modify bytes outside the mapped ranges, unmap one, remap, etcetc?

-- 
Antti Kantee <pooka@iki.fi>                     Of course he runs NetBSD
http://www.iki.fi/pooka/                          http://www.NetBSD.org/
    "la qualité la plus indispensable du cuisinier est l'exactitude"